express - How to setup log level in Winston/Node.js? -
I have my node Using Winston Logging with JS App and I defined a file transport. During my code, I'm either My question is, how do I specify the log level? Is there a config file and the value that I can set so that only logical log messages are logged? For example, I want to log in level "information" in my development environment, but want "error" in production. It seems that the options passed are a level option that From the doctor: Now, those examples show the passing level in the console object's choice object. When you use a file transport, I believe that you will pass an object object, which includes not only the file path but also the level. This should do something like this: According to that doctor, also keep in mind that as 2.0, it exposes a setLevel method to change on runtime. Look in the Log Level Use section of that document. logger. Log in using Terror ,
logger.warn , or
logger.info .
var logger = new (winston.Logger) ({transports: [Newton (Winston. TransportSource console) ({level: 'error'}), new (Winston.transportance. File) ({filename: 'somefile.log'})}});
Var Logger = new (Winston Loger) ({transports: [New (Winston.transpaces.file) ({filename: Somefile.log ', level:' error '})]});
Comments
Post a Comment