Do you need a simple file based log server? #npm #nodejs #javascript

Oscar Brito

It has been a very busy month that was translated in just a few hours of work on my opensource/closesource projects. I'm really looking forward to continue my work on divhide-core library on the weeks to come!

On these busy weeks I had the need to use a simple log system that I could easily integrate with mobile devices in order to track what is happening.

When doing my research I was searching for something with:

  • Simple installation process
  • Simple configuration
  • Support to multiple log names
  • No DB dependency
  • Web view interface

I found a couple of results, but none that ticks all the boxes, so I created my own log-server. With some nodejs magic I just had to code a few lines of code to make this happen.

The package is available on https://www.npmjs.com/package/log-server.

log-server

To execute our log server we just need to run:

# install log-server
npm i log-server -g

# set log-server to store the logs on '/tmp/logs/' folder
log-server -p 8000 -d /tmp/logs/

With the log server running you have access to a web based file viewer.

log-server client

To send your local logs to the server a simple HTTP POST is enough.

You should POST against http://localhost:8000/LOGNAME/log, where LOGNAME is the name of the log.

The logfile will be created if it does't exists, and the POST body will be appended to this file. After the file is created it will be visible on the web interface.

caveats

Because this was created to be used while on the developing phase there was no security concerns. This means that anyone can POST logs

Also, there's a 10MB limitation per request, to limit the quantity of information per request and not overload the nodejs process memory.

I'm sure you can find more limitations and please feel free to contribute.

Oscar out.