-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I use approach with EcheptionHandler:
builder.Services.AddExceptionHandler();
app.UseExceptionHandler(_ => { });
And I have two logs from Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware and WebApi.RequestHandle.ExceptionHandler. I disable ExceptionHandlerMiddleware:
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware": "None"
}
}
builder.Logging.ClearProviders();
builder.Logging.AddAzureWebAppDiagnostics();
builder.Logging.AddFilter("Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware", LogLevel.None);
localy in Visual studio it work correct, but when I deploy in azure app service in Azure Log stream I see both logs.
How I can disable Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware for Azure Log stream
Expected Behavior
I need one log from ExceptionHandler
Steps To Reproduce
No response
Exceptions (if any)
2024-08-30 14:35:54.741 +00:00 [Information] Microsoft.AspNetCore.Routing.EndpointMiddleware: Executed endpoint 'CurrencyRate.WebApi.Controllers.WeatherForecastController.Get (CurrencyRate.WebApi)'
2024-08-30 14:35:54.742 +00:00 [Error] Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware: An unhandled exception has occurred while executing the request.System.NullReferenceException: Object reference not set to an instance of an object.at CurrencyRate.WebApi.Controllers.WeatherForecastController.<>c.b__4_0(Int32 index) in D:\a\CurrencyRate\CurrencyRate\CurrencyRate.WebApi\Controllers\WeatherForecastController.cs:line 33at System.Linq.Enumerable.SelectRangeIterator1.Fill(Span1 results, Int32 start, Func2 func)at System.Linq.Enumerable.SelectRangeIterator1.ToArray()at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)at CurrencyRate.WebApi.Controllers.WeatherForecastController.Get() in D:\a\CurrencyRate\CurrencyRate\CurrencyRate.WebApi\Controllers\WeatherForecastController.cs:line 33at lambda_method3(Closure, Object, Object[])at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()--- End of stack trace from previous location ---at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()--- End of stack trace from previous location ---at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task) 2024-08-30 14:35:54.757 +00:00 [Error] CurrencyRate.WebApi.RequestHandle.ExceptionHandler: Exception occured : Object reference not set to an instance of an object.System.NullReferenceException: Object reference not set to an instance of an object.at CurrencyRate.WebApi.Controllers.WeatherForecastController.<>c.<Get>b__4_0(Int32 index) in D:\a\CurrencyRate\CurrencyRate\CurrencyRate.WebApi\Controllers\WeatherForecastController.cs:line 33at System.Linq.Enumerable.SelectRangeIterator1.Fill(Span1 results, Int32 start, Func2 func)at System.Linq.Enumerable.SelectRangeIterator1.ToArray()at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)at CurrencyRate.WebApi.Controllers.WeatherForecastController.Get() in D:\a\CurrencyRate\CurrencyRate\CurrencyRate.WebApi\Controllers\WeatherForecastController.cs:line 33at lambda_method3(Closure, Object, Object[])at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()--- End of stack trace from previous location ---at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()--- End of stack trace from previous location ---at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
.NET Version
8.0
Anything else?
No response