2

Using Azure Function and Log Stream I'm flooded by these types of logs at the "Information" log level:

2023-08-17T21:00:44Z   [Information]   Executed DbCommand (2ms)....

How can I change the log level for the executed DbCommand to log under Trace instead of Information so I'm not flooded w/ these log entries?

I've added the following Configuration -> Application Settings in Azure however I'm still seeing the log entries as Information:

Name: AzureFunctionsJobHost__logging__logLevel__Microsoft
Value: Trace
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
99823
  • 2,407
  • 7
  • 38
  • 60

1 Answers1

1

You can use ConfigureWarnings on the context options builder and set the level in Log(ValueTuple<EventId,LogLevel>[]):

services.AddDbContext<AppContext>(builder =>
  builder.Use...(...)
    .LogTo(Console.WriteLine, LogLevel.Information)
    .ConfigureWarnings(b => b.Log((RelationalEventId.CommandExecuted, LogLevel.Trace)))
);

Alternatively you can just use Ignore to completely disable the event.

Guru Stron
  • 102,774
  • 10
  • 95
  • 132