Exemple #1
0
 /// <summary>
 /// Initializes a new instance of MSToolKit.Core.Filters.LoggingExceptionHandler.
 /// </summary>
 /// <param name="next">The function that process the current HTTP request.</param>
 /// <param name="logger">The instance for Microsoft.Extensions.Logging.ILogger, that will log the occured errors.</param>
 /// <param name="hostingEnvironment">The current instance of Microsoft.AspNetCore.Hosting.IHostingEnvironment.</param>
 /// <param name="options">
 /// An instance of MSToolKit.Core.Filters.Options.ExceptionHandlerOptions,
 /// that configures the behavior of the exception handler.
 /// </param>
 public LoggingExceptionHandler(
     RequestDelegate next,
     ILogger <LoggingExceptionHandler> logger,
     IHostingEnvironment hostingEnvironment,
     LoggingExceptionHandlerOptions options)
 {
     this.next               = next;
     this.logger             = logger;
     this.hostingEnvironment = hostingEnvironment;
     this.options            = options;
 }
Exemple #2
0
        public static IApplicationBuilder UseLoggingExceptionHandler(
            this IApplicationBuilder app, Action <LoggingExceptionHandlerOptions> exceptionOptions)
        {
            var options = new LoggingExceptionHandlerOptions();

            exceptionOptions(options);

            app.UseMiddleware <LoggingExceptionHandler>(options);

            return(app);
        }