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 logger. Log in using Terror , logger.warn , or logger.info .

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:

  var logger = new (winston.Logger) ({transports: [Newton (Winston. TransportSource console) ({level: 'error'}), new (Winston.transportance. File) ({filename: 'somefile.log'})}});   

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:

  Var Logger = new (Winston Loger) ({transports: [New (Winston.transpaces.file) ({filename: Somefile.log ', level:' error '})]});   

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.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -