Node.js logger: winston

Winston is a fancy and flexible logging library developed by the guys from Nodejistu. It is totally decoupled allowing an easy extension and customization for any Node.js project.
In a configuration file I created a simple data structure log with the different levels of logging and respective colorization. Afterwards it is trivial to instantiate my own logger adding the so call “multi transport” supported by Winston which enables different storage devices (console, file, mail, etc). Finally I set the logging levels/colors previously defined, and I’m ready to go!
As aforementioned, Winston is highly flexible and supports many tweaks which are all thoroughly detailed in github.

var log = {
    'logger' : {
      'levels': {
        'detail': 0,
        'trace': 1,
        'debug': 2,
        'enter': 3,
        'info': 4,
        'warn': 5,
        'error': 6
      'colors': {
        'detail': 'grey',
        'trace': 'white',
        'debug': 'blue',
        'enter': 'inverse',
        'info': 'green',
        'warn': 'yellow',
        'error': 'red'

  function getLogger() {
    var logger = new (winston.Logger)({
      'transports': [
      new (winston.transports.Console)(
        'level': 'enter',
        'colorize': true
      new (winston.transports.File)(
        'filename': 'logging-file.log'


    return logger;
Tagged , , , ,

One thought on “Node.js logger: winston

  1. anerkendelse says:

    What’s up, its nice post regarding media print, we all be familiar with media is a fantastic source of information.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: