I just plugged together Microsoft.Extensions.Logging and Serilog.Extensions.Logging and noticed that my log file was full of SQL queries, probably from here:
Is there any specific reason why query logging is on information log level and not on debug?
Is there a way of influencing this by configuration?
If you are using Serilog, you can use something like I use to filter our unwanted logs:
var configurations = new LoggerConfiguration()
.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
Use the desired log level for the source you want to override.
We worked together with ASP.NET Core to refine how the log output should look like for a typical request during development.
The decision was made that the SQL should be included in the log during development and the default logging level for our comments during development in the ASP.NET Core templates is Information
(see appsettings.Development.json).
The default logging level for an application in production in the default ASP.NET Core templates is Warning
(see appsettings.json) so in production the log should not include the SQL.
Is there a way to control the log level?
Could be really handy.
Because we do want log the SQL, but not many other things.
Now that I'm rethinking, maybe it's better using the code I posted earlier, control what to log in the logger itself. I'm not sure.
Most helpful comment
Is there a way to control the log level?
Could be really handy.
Because we do want log the SQL, but not many other things.
Now that I'm rethinking, maybe it's better using the code I posted earlier, control what to log in the logger itself. I'm not sure.