Created
May 28, 2014 09:53
-
-
Save GuillermoPena/064d0a71470b81ffe040 to your computer and use it in GitHub Desktop.
NodeJS - WINSTON : Logging with winston
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// More info here: https://github.com/flatiron/winston | |
// Simple Example | |
var winston = require('winston') | |
var mongoTransport = require('winston-mongodb').MongoDB | |
var defaultLogger = winston | |
defaultLogger.level = 'silly' | |
defaultLogger.silly("Default logger") | |
// Complex Example | |
var logger = new winston.Logger({ | |
transports: [ | |
new winston.transports.Console({ level: 'debug', colorize: true }), | |
new winston.transports.File({ filename: 'winston.log', json: false }), | |
new mongoTransport({ db: 'winston' }) // Default ({ collection: 'log', host: 'localhost', port: 27017}) | |
//new winston.transports.Redis() // Default: ({ host: 'localhost', port: 6379, auth: 'None' }) | |
], | |
colors: [{ | |
info: 'blue', | |
warn: 'yellow', | |
error: 'red' | |
}] | |
}) | |
logger.info(logger.levels) | |
logger.info("Hello", { metadata: "metadata" }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment