lumberjack

A simple logging framework for node.js, written in CoffeeScript and inspired by logback.

current version 0.3.0

 

Quick Start

 

Guide

Logging in lumberjack is about dispatching and handling logging-events. A logging event contains the log message, the level (severity), the dispatc time, and the name of the process.

Layouts

Responsible for transforming log entries to text. Currently there is only one layout: Pattern-Layout. To specify a pattern layout you assemble a string out of the following tokens (order matters):

  • p – process is
  • d – timestamp
  • m – message
  • l – level
  • L – logger

So, for example, in order to get entries like the ones shown in the introduction the following pattern is required: “p L l d m”.

Appenders

Responsible for writing out the text created by the layouts. there are console and file appenders.

Loggers

The driving force of the lumberjack universe. you use the to, well, log. Loggers have name, level, parent logger, and appenders.

Name

Loggers are named (can be reflected in the output). By using a ‘namespace’ like name you can create a hierarchy of loggers. For example: the names ‘service.io’ and ‘service.err’ create three loggers: ‘service.io’, ‘service.error’ and ‘service’. this fact is becomes important when dealing with levels and appenders (see next).

Level

The level of logging. Only log events that have a level that is equal to or greater then the logger’s level are handled. So, for example if you set a logger with level ‘INFO’ then debug and trace events on that logger will be ignored. If a level isn’t specified, the logger parent’s level becomes the effective level.

Parent

Every logger have a parent logger (except for the root logger which is the parent of all loggers and created by lumberjack upon startup).

Appenders

Each logger can have multiple appenders. Log events that have the right level are routed to all appenders and parent appenders as well. If no appenders are specified for a logger then the parent appenders are used. the root logger uses a console appender (with pattern layout).

Configuration

The configuration file is separated into two parts: appenders and loggers. following is an example configuration that specifies two loggers and two appenders:

%d bloggers like this: