1

I'm not able to disable the traceback on exceptions even after setting LOGURU_BACKTRACE environment variable as False. I've also tried logger.configure() method like this.

logger.configure(handlers=[
    {"sink": sys.stderr, "backtrace": False}
])

but loguru is still showing tracebacks on exceptions. Could someone guide me to disable the traceback?

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Dinesh Kumar
  • 483
  • 8
  • 24

1 Answers1

4

The backtrace attribute controls the length of the traceback (if enabled, Loguru displays the entire traceback instead of stopping at the try/except frame like the standard exception does).

However, Loguru respects the sys.tracebacklimit value. You can disable traceback by settings it to 0:

import sys

sys.tracebacklimit = 0

If advanced exception formatting configuration is required, you can define your own way of displaying exceptions by using a custom format function as explained in the documentation: Customizing the formatting of exceptions.

Dinesh Kumar
  • 483
  • 8
  • 24