Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi All ,
I have implemented exception handler in startup to catch exceptions globally, however exceptions throw from Notification handlers are not logged.
Any assistance is greatly appreciated.
tried below two options
Using Exception handler: registered UseExceptionHandler middleware early in the pipeline as below.
app.UseExceptionHandler( builder => builder.Run(async context => {var exceptionHandlerPathFeature = context.Features.Get<IExceptionHandlerPathFeature>(); var exception = exceptionHandlerPathFeature?.Error; logger.LogError(exception, exception?.Message); await context.Response.WriteAsJsonAsync( new ExceptionResponse() { Message = exception?.Message, }); }));
var exception = exceptionHandlerPathFeature?.Error; logger.LogError(exception, exception?.Message); await context.Response.WriteAsJsonAsync( new ExceptionResponse() { Message = exception?.Message, }); }));
But seems both are not working.
I found the information here to be helpful: https://enlear.academy/global-exception-handling-in-net-6-16908fc8dc28
I created a custom class in a new Middleware folder called Startup and did this:
namespace Umbraco_Project.Middleware; public static class Startup { public static IApplicationBuilder UseGlobalExceptionHandler(this IApplicationBuilder app) => app.UseMiddleware<ExceptionMiddlewareV2>(); }
Then I injected this in the main Startup.cs file instead of the Program.cs like this:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseGlobalExceptionHandler(); ... }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Global exception handling and logging in umbraco 10
Hi All ,
I have implemented exception handler in startup to catch exceptions globally, however exceptions throw from Notification handlers are not logged.
Any assistance is greatly appreciated.
tried below two options
Using Exception handler: registered UseExceptionHandler middleware early in the pipeline as below.
But seems both are not working.
I found the information here to be helpful: https://enlear.academy/global-exception-handling-in-net-6-16908fc8dc28
I created a custom class in a new Middleware folder called Startup and did this:
Then I injected this in the main Startup.cs file instead of the Program.cs like this:
is working on a reply...