Closed codecontemplator closed 5 years ago
Hi @codecontemplator, thanks for raising this.
You can access the mapped status code via the httpContext argument (httpcontext.Response.StatusCode
).
Is this what you were looking for or have I misunderstood your question?
Thanks, Joe
Hi, @JosephWoodward thanks for your reply.
when I try to access httpContext.Response.StatusCode it always gives me 500 internal server error.
Could you please tell me if I am missing something.
I experience the same thing. It seems like the OnError (logger) is invoked before the status code is resolved.
yeah @codecontemplator, I think _logger can be invoked after resolving status code.
@dharanish @codecontemplator So it does! My test tests against a 500 which is why it was passing, I'll get that fixed.
Thanks!
Is it possible to provide any update on this issue.?
@dharanish Yeah, working on a solution - hoping to get it out in the next few days. Ultimately I've created an overload that gives you some different options then I'll retire the older one ((Exception, HttpContext)
) in the next major version release.
Sorry it's taken me so long to get around to fixing this, however it's now been fixed in 4.0.1 which can be found on NuGet here. Decided to hold off on the above solution and instead just moved setting the status code before the log delegate is invoked. I'll close this issue now but please do let me know if there are any problems! 😄
In order to categorize my logging entry I would like to have access to the mapped status code. For example: