Skip to content

Instantly share code, notes, and snippets.

@electblake
Last active August 30, 2015 15:21
Show Gist options
  • Select an option

  • Save electblake/564a49bec8abb0e536b3 to your computer and use it in GitHub Desktop.

Select an option

Save electblake/564a49bec8abb0e536b3 to your computer and use it in GitHub Desktop.
var fs = require('fs-extra'),
path = require('path'),
bunyan = require('bunyan');
var logDir = path.resolve(path.join('./', 'log'));
fs.ensureDir(logDir);
module.exports = bunyan.createLogger({
name: 'app-name',
streams: [
{
level: 'debug',
stream: process.stdout
},
{
level: 'error',
type: 'rotating-file',
path: path.join(logDir, 'error.log'),
period: '1d', // daily rotation
count: 3 // keep 3 back copies
},
{
level: 'info',
type: 'rotating-file',
path: path.join(logDir, 'run.log'),
period: '1d', // daily rotation
count: 1 // keep 3 back copies
},
{
level: 'debug',
type: 'rotating-file',
path: path.join(logDir, 'debug.log'),
period: '1h',
count: 3
}
]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment