Skip to content

Instantly share code, notes, and snippets.

@heapwolf
Created May 7, 2012 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heapwolf/2628409 to your computer and use it in GitHub Desktop.
Save heapwolf/2628409 to your computer and use it in GitHub Desktop.
winston with multiple files
var logger = new (winston.Logger)({
  level: 'NORMAL',
  levels: {
    INFO: 1,
    TEST: 2,
    CRITICAL: 3
  },
  colors: {
    VERBOSE: 'green',
    CRITICAL: 'red'
  },
  transports: [
    new winston.transports.Console({ level: 'INFO' }),
    new winston.transports.File({ filename: __dirname + '/../../logs/csock.log', level: 'CRITICAL' }),
    new winston.transports.File({ filename: __dirname + '/../../logs/dump.log', level: 'DUMP' })
  ]
});
node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Transport already attached: file
    at [object Object].add (/Users/paolo/workroot/git/nodejitsu/cloudsockets/node_modules/winston/lib/winston/logger.js:274:11)
    at /Users/paolo/workroot/git/nodejitsu/cloudsockets/node_modules/winston/lib/winston/logger.js:64:12
    at Array.forEach (native)
    at new <anonymous> (/Users/paolo/workroot/git/nodejitsu/cloudsockets/node_modules/winston/lib/winston/logger.js:63:24)
    at Object.<anonymous> (/Users/paolo/workroot/git/nodejitsu/cloudsockets/lib/csock/common.js:85:14)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment