Skip to content

Instantly share code, notes, and snippets.

@barretts
Created May 16, 2015 02:25
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save barretts/ae7fff301168ef623611 to your computer and use it in GitHub Desktop.
Save barretts/ae7fff301168ef623611 to your computer and use it in GitHub Desktop.
Sails.js configuration to use Winston logger output to file
var winston = require('winston');
/*
Sails.js Winston logger config
I was having trouble getting the logfile output to be verbose, having copied several from the web I finally came
up with this setup after reading the old Captian's Log configuration. Current problem is the doubling of verbose.
ex: verbose: verbose: Grunt :: Running "sails-linker:devStyles" (sails-linker) task
*/
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)( {
level: 'verbose',
colorize: false,
json: false
} ),
new (winston.transports.File)({
filename: 'logfile.log',
level: 'verbose',
colorize: false,
json: false
})
]
});
module.exports.log = {
/***************************************************************************
* *
* Valid `level` configs: i.e. the minimum log level to capture with *
* sails.log.*() *
* *
* The order of precedence for log levels from lowest to highest is: *
* silly, verbose, info, debug, warn, error *
* *
* You may also set the level to "silent" to suppress all logs. *
* *
***************************************************************************/
level: 'verbose',
colorize: false,
json: false,
custom: logger
};
@danielgranat
Copy link

Looking for an example on how to configure winston with sails i found this very helpful!
As for the double of the level, wouldn't adding this showLevel:false solve the problem?

@macpatel
Copy link

macpatel commented Mar 1, 2018

thanks man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment