Suppressing stack trace for logger.catch()
See original GitHub issueIs there a way to suppress the stack trace for logger.catch()
?
I have a decorator that catches certain types of exceptions and calls logger.exception()
or logger.error()
, depending on a debug
boolean value. I’m trying to rewrite it using logger.catch()
, but it always outputs the full stack trace.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Prevent stack trace logging for custom exception in Spring ...
I am using spring boot to create a simple rest service. I like that for a custom exceptions there is no stack trace...
Read more >How to prevent Internal Server Error Stack Trace from being ...
When ReportsController throws an uncaught exception the Stack trace is translated into the HTTP response (status code 500)
Read more >ERR00-J. Do not suppress or ignore checked exceptions
Printing the exception's stack trace can be useful for debugging purposes, but the resulting program execution is equivalent to suppressing the exception.
Read more >Exceptional Logging of Exceptions in Python - Loggly
getLogger() , for example.) This wonderful method captures the full stack trace in the context of the except block, and writes it in...
Read more >Throwable (Java Platform SE 7 ) - Oracle Help Center
Over time, a throwable can suppress other throwables from being propagated. ... Sets the stack trace elements that will be returned by getStackTrace()...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, sorry, I get it! Indeed, it is not possible to completely remove the stacktrace with
logger.catch()
. You implemented a custom context manager and that’s the best thing to do I think.@Delgan Can you accept PR for this?
I thought about adding
backtrace
parameter tologger.catch()
and check it to setbacktrace_
toNone
inCatcher