-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
structlog not sending exc_info=True to logging wrapper #204
Comments
Is this a dupe of #200? |
No wait, this is the opposite. Just remove structlog.processors.format_exc_info from your processors and you should be fine. It takes exc_info and renders it into an exception key. |
I ran into the same issue and it can be reproduced with the default logger: import structlog
logger = structlog.get_logger()
try:
1/0
except:
logger.exception("Does not print the exception")
logger.exception("Prints the exception", exc_info=True) The corresponding output with structlog
|
I think the issue is here: https://github.com/hynek/structlog/blob/19.1.0/src/structlog/_loggers.py#L80 Pure structlog / print logger just assumes So structlog is not exactly a drop-in replacement for stdlib when used within an except block. Perhaps we could find a way that usage of the exception method will also inject btw, I think this is again #130 (which was closed). |
@vxgmichel Your problem is a #200 dupe. Danny was complaining that after configuring @wimglenn You too are in the wrong ticket and the class you're referring to is the wrong end: it's the one that only writes out the result. The interesting one is the generic BoundLogger which is the interface to the user. I'm closing this because the original problem is solved by my first response to Danny. This problem keeps coming up but as I've explained in #130, I cannot change the behavior of the default BoundLogger lest I want to break thousands of systems. But I do agree that it is unfortunate, that |
I'm having an issue when I use structlog to emit errors:
That will remove the
exc_info=True
flag from the log so the baselogging
package can't pick that up and get the exception stack. I know this is true because I stepped through the code until I got to the stdlib logging package, andexc_info
wasNone
This is my configuration:
The text was updated successfully, but these errors were encountered: