question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suppressing stack trace for logger.catch()

See original GitHub issue

Is 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:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Delgancommented, Apr 24, 2021

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.

0reactions
a5r0ncommented, Mar 25, 2022

@Delgan Can you accept PR for this?
I thought about adding backtrace parameter to logger.catch() and check it to set backtrace_ to None in Catcher

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found