‘m using Serilog in my .NET application along with Serilog.Sinks.GoogleCloudLogging to send logs to Datadog. I would like to automatically elevate all SQL exceptions (SqlException) to the Fatal (or Critical) log level, regardless of how they are initially logged (e.g., Error or Warning).
I’ve tried using enrichers and filters, but it seems the log level isn’t effectively modified before it reaches the sink, and logs still appear with their original log level in Datadog (e.g., Error instead of Fatal).
What I’ve tried:
-
Custom Enricher: I created an enricher to detect and modify SqlException log events. However, the log level remains unchanged in Google Cloud Logging.
-
Filters: I applied filters to elevate SqlException logs to Fatal level, but this didn’t work as expected with the Google Cloud Logging sink.
-
ExceptionHandlingMiddleware: I also tried a middleware to catch exceptions globally and modify the log level before logging, but the level still shows as Error instead of Fatal in Google Cloud.
Is there a way to modify the log level for all SqlException log entries to be logged as Fatal when using Serilog.Sinks.GoogleCloudLogging?