I have an azure function (.net 6, isolated) I use serilog and want to suppress all SQL output into console.
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(s =>
{
s.AddLogging(lb =>
{
lb.AddSerilog(new LoggerConfiguration()
.MinimumLevel.Override("Microsoft.Azure", LogEventLevel.Warning)
.Enrich.FromLogContext()
.MinimumLevel.Information()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("System", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore.Database.Command", LogEventLevel.Warning)
.WriteTo.Sentry(o =>
{
// Debug and higher are stored as breadcrumbs (default is Information)
o.MinimumBreadcrumbLevel = LogEventLevel.Debug;
// Warning and higher is sent as event (default is Error)
o.MinimumEventLevel = LogEventLevel.Warning;
o.Dsn = "https://xxx@yyy.ingest.sentry.io/zzz";
})
.WriteTo.Console(restrictedToMinimumLevel:LogEventLevel.Warning)
.CreateLogger());
});
But when the azure function operates on database it gives me an SQL output. in the host.json I have
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
Did I miss anything to turn off the Entity Framework information level?
It seems to me that
.WriteTo.Console(restrictedToMinimumLevel:LogEventLevel.Warning)
doesn't make a difference because when I comment it out, I still received a console output.