public static IApplicationBuilder UseRequestLogger(this IApplicationBuilder builder, Action <RequestLoggerOptions> configureOptions)
        {
            var options = new RequestLoggerOptions();

            configureOptions(options);
            return(builder.UseMiddleware <RequestLoggerMiddleware>(options));
        }
Ejemplo n.º 2
0
        public RequestLoggerMiddleware(RequestDelegate next, RequestLoggerOptions options = null)
        {
            _next    = next;
            _options = options ?? new RequestLoggerOptions();

            if (_options.ShouldUseColor && !Console.IsOutputRedirected)
            {
                _logger = new ColorfulRequestLogger(_next);
            }
            else
            {
                _logger = new PlainRequestLogger(_next);
            }
        }