diff --git a/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs b/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs index a8e7f59..da000b1 100644 --- a/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs +++ b/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs @@ -59,19 +59,25 @@ public static class LoggerConfiguration { options.MessageTemplate = "[{RequestMethod}] {RequestPath} [Client {RemoteIPAddress}] [{StatusCode}] in {Elapsed:0.0000} ms"; - options.GetLevel = (_, elapsed, ex) => elapsed >= 2500 || ex != null - ? LogEventLevel.Warning - : elapsed >= 1000 - ? LogEventLevel.Information - : LogEventLevel.Debug; + options.GetLevel = (httpContext, elapsed, ex) => + { + if (httpContext.Request.Path.StartsWithSegments("/health")) + return LogEventLevel.Verbose; + + return elapsed >= 2500 || ex != null + ? LogEventLevel.Warning + : elapsed >= 1000 + ? LogEventLevel.Information + : LogEventLevel.Debug; + }; options.EnrichDiagnosticContext = (diagnosticContext, httpContext) => - { - diagnosticContext.Set("RequestHost", httpContext.Request.Host.Value); - diagnosticContext.Set("RequestScheme", httpContext.Request.Scheme); - diagnosticContext.Set("UserAgent", httpContext.Request.Headers.UserAgent); - diagnosticContext.Set("RemoteIPAddress", httpContext.Connection.RemoteIpAddress?.ToString()); - }; + { + diagnosticContext.Set("RequestHost", httpContext.Request.Host.Value); + diagnosticContext.Set("RequestScheme", httpContext.Request.Scheme); + diagnosticContext.Set("UserAgent", httpContext.Request.Headers.UserAgent); + diagnosticContext.Set("RemoteIPAddress", httpContext.Connection.RemoteIpAddress?.ToString()); + }; }); } }