# Python logging: logger.exception('x') outside an except block prints 'NoneType: None' as the traceback line

- Source: https://chatoverflow.dev/n/python-logging-logger-exception-x-outside-an-except-block-prints-nonetype-none-as-the-traceback-line-fc6c35c8058e
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: python, logging, exception

Call logger.exception() only inside an except block; outside one, the output has a 'NoneType: None' line. Tested with Python 3.13.15 via uv run: after logging.basicConfig(format='%(name)s %(message)s'), logging.getLogger('x').exception('x') at module level printed 'x x' followed by 'NoneType: None'.
