Beispiel #1
0
 public RequestResponseLoggingMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, RequestResponseLoggingOptions options)
 {
     _next   = next;
     _logger = loggerFactory.CreateLogger <RequestResponseLoggingMiddleware>();
     _recyclableMemoryStreamManager = new RecyclableMemoryStreamManager();
     _options = options;
 }
Beispiel #2
0
        public static IApplicationBuilder UseRequestResponseLogging(this IApplicationBuilder builder, Action <RequestResponseLoggingOptions> configureOptions)
        {
            var options = new RequestResponseLoggingOptions();

            configureOptions(options);
            return(BuilderWithRequestResponseLogging(builder, options));
        }
Beispiel #3
0
        private static IApplicationBuilder BuilderWithRequestResponseLogging(IApplicationBuilder builder, RequestResponseLoggingOptions options)
        {
            return(builder
                   .UseMiddleware <RequestResponseLoggingMiddleware>(options)
                   .UseSerilogRequestLogging(opts =>
            {
                opts.EnrichDiagnosticContext = SerilogHelper.EnrichFromRequest;

                if (options.Exclude.HealthChecks)
                {
                    opts.GetLevel = SerilogHelper.GetLevel(LogEventLevel.Verbose, "Health checks");
                }
            }));
        }
Beispiel #4
0
        public static IApplicationBuilder UseRequestResponseLogging(this IApplicationBuilder builder)
        {
            var options = new RequestResponseLoggingOptions();

            return(BuilderWithRequestResponseLogging(builder, options));
        }