awesomeeng / awesome-log

Logging for enterprise ready nodejs applications.
MIT License
34 stars 4 forks source link

Is there a way to tell AL not to log debug logs? #30

Closed optikalefx closed 1 year ago

optikalefx commented 1 year ago

We'd like to use an ENV var to tell prod not to log debug logs. I don't see anything in the docs that allow for this. Is it possible that I'm not seeing?

Thanks!

arei commented 1 year ago

In thge config you pass to Log.init() you can specify what log levels go to what writers. So

Log.init({
  writers: [{
    name: 'my-console-logger',
    type: 'console',
    levels: 'info,warn,error,access',  // This comma separated list can control what levels get written.
    formatter: 'json'
  }],
});

Bit more here: https://github.com/awesomeeng/awesome-log/blob/master/docs/Configuration.md#writer-configuration

For the ENV portion you will need to figure that out yourself, but you're a smart guy. :)