Remove some logs from db
This commit is contained in:
@@ -132,18 +132,8 @@ builder.Services.AddDbContext<ManagingDbContext>((serviceProvider, options) =>
|
||||
// Enable service provider caching for better performance
|
||||
options.EnableServiceProviderCaching();
|
||||
|
||||
// Enable SQL query logging for warnings and errors only (reduced logging)
|
||||
var logger = serviceProvider.GetRequiredService<ILogger<ManagingDbContext>>();
|
||||
var sentryMonitoringService = serviceProvider.GetRequiredService<SentrySqlMonitoringService>();
|
||||
|
||||
options.LogTo(msg =>
|
||||
{
|
||||
// Log only warnings and errors to reduce log volume
|
||||
if (msg.Contains("Warning") || msg.Contains("Error"))
|
||||
{
|
||||
Console.WriteLine($"[EF-WARNING] {msg}");
|
||||
}
|
||||
}, LogLevel.Warning); // Log only warnings and errors to reduce SQL log volume
|
||||
// Disable SQL query logging to reduce log volume (only errors will be logged via standard logging)
|
||||
// SQL monitoring is handled by SentrySqlMonitoringService which respects LogSlowQueriesOnly setting
|
||||
}, ServiceLifetime.Scoped); // Explicitly specify scoped lifetime for proper request isolation
|
||||
|
||||
// Add specific health checks for databases and other services
|
||||
@@ -177,6 +167,7 @@ builder.Host.UseSerilog((hostBuilder, loggerConfiguration) =>
|
||||
};
|
||||
|
||||
loggerConfiguration
|
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore.Database.Command", LogEventLevel.Warning) // Filter out EF Core SQL query logs
|
||||
.WriteTo.Console()
|
||||
.WriteTo.Elasticsearch(es);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user