Example #1
0
        /// <summary>
        /// Adds the request logging middleware to the application pipeline.
        /// </summary>
        /// <param name="builder">An application builder.</param>
        /// <param name="configureOptions">An optional action that can be used to configure the middleware options.</param>
        public static IApplicationBuilder UseSerilogRequestLogging(this IApplicationBuilder builder, Action <RequestLoggingOptions> configureOptions = null)
        {
            var options = new RequestLoggingOptions();

            configureOptions?.Invoke(options);
            return(builder.UseMiddleware <SerilogRequestMiddleware>(options));
        }
Example #2
0
 public SerilogRequestMiddleware(RequestDelegate next, ILogger logger, RequestLoggingOptions options)
 {
     _next    = next ?? throw new ArgumentNullException(nameof(next));
     _logger  = logger?.ForContext <SerilogRequestMiddleware>() ?? throw new ArgumentNullException(nameof(logger));
     _options = options ?? throw new ArgumentNullException(nameof(options));
 }