Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For the EnrichDiagnosticContext Func maybe pass either the statusCode or the exception variable. #220

Open
EraYaN opened this issue Nov 26, 2020 · 0 comments

Comments

@EraYaN
Copy link

EraYaN commented Nov 26, 2020

Is your feature request related to a problem? Please describe.
My main problem is that I want to log more when there has been an exception. And the response code at this point is still 200 in the httpContext.Response object. So I need a separate custom middleware to achieve the desired result.

Describe the solution you'd like
So pass either the ex variable (just like to _getLevel) or the statusCode so I don't need one more Middleware to just do logging when there has been an exception.

Describe alternatives you've considered
You can add an extra Middleware that add these variables to the DiagnosticContext itself.

Extra context
For example:

            if (httpContext.Response.StatusCode > 499)
            {
               // attach immense amounts of stuff. for later debugging
            }

Does not work with Exceptions, since the StatusCode is still 200 at that point the 500 gets passed as a different parameter in the Middleware completion function.

I'd like to do something like:

            if (ex != null || statusCode > 499)
            {
               // attach immense amounts of stuff. for later debugging
            }

I'm not sure how you could add these two without breaking existing code, even if it would be an easy fix with the new discarded _ arguments for users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant