node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org ยป



Collect logs from a distributed network and parse them with connect-style middleware

Simply by connecting client instances on your production machines to a server instance (normally run on it's own machine) you can set up a single point to parse, record, and analyze all your crucial logs.

You can even hook it up with and connect/express to build a web page with dynamic information based on your logs


Simply install using npm, it is recommended that you install it globally to obtain the lozigo command, which will spin up a client

npm install -g lozigo


The configuration file is purely JSON, here is an example one which would be read by the client instance

  "client_name": "Example",
  "server_port": "8181",
  "logs": [
    { "name": "First Log",
      "path": "/Users/alexangelini/Local/lozigo/examples/log1.txt" },
    { "name": "Second Log",
      "path": "/Users/alexangelini/Local/lozigo/examples/log2.txt" }


To run a client instance simply

lozigo /path/to/config.json

And to set up a server simply copy example.js in the examples folder

var lozigo = require('../lib/lozigo');
var app = lozigo.createServer();

app.listen(8181, function() {
  console.log('Listening on: ' + PORT);


Just like connect's middleware system, you tell lozigo's app to use functions with the following arguments

function(entry, acc, next) {}
  • "entry": Is an object which includes info about the log and the line which was captured
  • "acc": Is an accumulator, an empty object to store information in as the entry is passed through the middleware
  • "next": Is a function which takes the entry and the accumulator as arguments, and launches the next middleware function

To connect them to your app simply call the 'use' function

var lozigo = require('../lib/lozigo');
var app = lozigo.createServer();

app.use(function(entry, acc, next) {
  console.log('Current entry-->', entry);

app.listen(8181, function() {
  console.log('Listening on: ' + PORT);


Here is an example entry

  data: 'Test 13\n',
  date: 1323752580753,
    { name: 'Second Log',
      path: '/Users/alexangelini/Local/lozigo/examples/log2.txt' },
  client_name: 'Example' 

Example Middleware

Here are some included middlewares, which provide a simple example of what can be done.



This builds an array of keywords taken from the log line, and adds that array to the accumulator. This is useful when building search indexes for your logs or to notify you of the frequency of certain keywords.


// To print to the console

// To append to a file

// To append to a file and not include meta data
  file_path: '/combination/log/path',
  include_meta: false

This is used to combine all your logs from all your running instances of the lozigo client into a single log with all the meta-data stored. This is useful for making backups.