GithubHelp home page GithubHelp logo

Comments (8)

khellang avatar khellang commented on June 2, 2024

Hi @ismaelbl! 👋🏻

I don't understand what the issue is. You've configured the middleware to rethrow ArgumentException. Why do you think it's an issue when an ArgumentException has been rethrown and logged in the request logging middleware?

from middleware.

ismaelbl avatar ismaelbl commented on June 2, 2024

Hi @khellang. The problem it seems the same described in #104. The actual logging works fine, but it should just write this part:

NT|WEBAP|Aplicación|Anónimo|2023-01-23 16:06:18|Estado: 500|System.ArgumentException: patata
   at ClasesSenFume.Api.Controllers.CentrosController.GetAll(CentroFilterViewModel filter) in C:\Users\ismaelbl\Desktop\Proyectos\ClasesSenFume\sw-csf\src\ClasesSenFume.Api\Controllers\CentrosController.cs:line 48
   at lambda_method(Closure , Object )
   at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   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 where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Hellang.Middleware.ProblemDetails.ProblemDetailsMiddleware.Invoke(HttpContext context)
   at Hellang.Middleware.ProblemDetails.ProblemDetailsMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)
   at Hellang.Middleware.ProblemDetails.ProblemDetailsMiddleware.Invoke(HttpContext context)
   at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext) 

The entry below the first one seems to be produced by the aforementioned issue.

from middleware.

khellang avatar khellang commented on June 2, 2024

#104 is a completely different issue. The issue was that even though the exception was rethrown, the response ended up being empty.

from middleware.

ismaelbl avatar ismaelbl commented on June 2, 2024

Ok, I thought it might have to do with the other issue because it's printting the Connection id "0HMNTADB12UF5", Request id "0HMNTADB12UF5:00000001": An unhandled exception was thrown by the application. message.

Sorry if it's not the case, does it occur to you what could be happening? Thanks.

from middleware.

khellang avatar khellang commented on June 2, 2024

It's hard to say what's happening as the code is incomplete and I don't know what the response looks like. To me, it looks like the request logging and problem details middleware are doing what they're supposed/configured to.

from middleware.

ismaelbl avatar ismaelbl commented on June 2, 2024

Yes, it actually working as I spected, but for some reason it's printting two times the same exception. In the last one without the intervention of request logging. I will try to dig up more information next week.

from middleware.

ismaelbl avatar ismaelbl commented on June 2, 2024

Hi, there. In the end the problem was caused by Serilog request logging. I solved it following serilog/serilog-aspnetcore#270. Instead of rethrowing the exception I set it via IDiagnosticContext.

from middleware.

bartpio avatar bartpio commented on June 2, 2024

Good approach. I faced a similar issue and came up with a small library containing trivial middleware that sets exceptions in IDiagnosticContext before ProblemDetails handles them.

from middleware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.