Last active
March 29, 2026 20:50
-
-
Save AlexanderHott/b14778766b28c4e8dfc8f68bea0d9c06 to your computer and use it in GitHub Desktop.
Python logging config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # For an explanation and more advanced setup, see this video from mCoding https://www.youtube.com/watch?v=9L77QExPmI0 | |
| import logging | |
| import logging.config | |
| logging.config.dictConfig( | |
| { | |
| "version": 1, | |
| "disable_existing_loggers": False, | |
| "formatters": { | |
| "simple": { | |
| "format": "[%(asctime)s .%(msecs)03d|%(levelname)s|%(name)s|%(filename)s:%(lineno)d] %(message)s", | |
| "datefmt": "%Y-%m-%dT%H:%M:%S%z", | |
| } | |
| }, | |
| "handlers": { | |
| "stdout": { | |
| "class": "logging.StreamHandler", | |
| "formatter": "simple", | |
| "stream": "ext://sys.stdout", | |
| # "level": "WARNING", | |
| "level": "INFO", | |
| # "level": "DEBUG", | |
| }, | |
| }, | |
| "loggers": { | |
| "root": { | |
| "level": "DEBUG", | |
| "handlers": [ | |
| "stdout", | |
| ], | |
| } | |
| }, | |
| } | |
| ) | |
| logger = logging.getLogger("app") | |
| # ... | |
| logger.info(f"Something happened {var1=} {var2=}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.