Skip to content

Instantly share code, notes, and snippets.

@ingshtrom
Last active August 29, 2015 14:05
Show Gist options
  • Save ingshtrom/90f5ba133bed306a8255 to your computer and use it in GitHub Desktop.
Save ingshtrom/90f5ba133bed306a8255 to your computer and use it in GitHub Desktop.
The default logger config I use for my projects (minus loggly and logentries)
var winston = require('winston'),
config = require('./config');
var consoleConfig, fileConfig;
// MODULE API
module.exports.logger = configure();
// MODULE IMPLEMENTATIONS
function configure () {
// add our custom transports for all loggers
consoleConfig = {
level: config.consoleLogLevel,
colorize: true,
handleExceptions: false,
timestamp: true
};
fileConfig = {
filename: config.defaultLogFile,
level: config.fileLogLevel,
maxsize: 102400,
handleExceptions: true,
timestamp: true
};
winston.exitOnError = true;
return new (winston.Logger)({
transports: [
new (winston.transports.Console)(consoleConfig),
new (winston.transports.File)(fileConfig)
]
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment