Disable internal logging
dmytrohridin opened this issue · comments
Use case
Our application writes a lot of info into logs, but the library produces some info logs too, that is redundant for us.
For sure, we can somehow filter messages produced by the library.
Proposal
Implement enabling/disabling logging for the library or make library log level configurable (i.e. write only errors)
If idea makes sense - I can submit PR
Thank you
Hi @dmytrohridin, would it be possible to just disable it with logging configuration like this:
{
"Logging": {
"LogLevel": {
/* ... */
"CorrelationId": "Error"
}
},
"AllowedHosts": "*"
}
... this will keep logging errors (currently only when correlation ID is not configured), or you can set value to None
.
@wdolek I tried in this way, but it's not working (I use Serilog)
@dmytrohridin I haven't used Serilog much yet, but this looks like configuration which could help (Serilog 2.1+):
Log.Logger = new LoggerConfiguration()
// ...
.MinimumLevel.Override("CorrelationId", LogEventLevel.Error);
... or there may be other ways of filtering. I can understand that adding bool flag would be the easiest for user though.
@wdolek nice idea, will try, thank you
it works, thank you, will close issue
Thanks for providing the solution @wdolek!