Created
February 10, 2022 07:41
-
-
Save Rustam-Z/91d2e7e74098c82c6d1f35abff353d62 to your computer and use it in GitHub Desktop.
Python logging module
This file contains 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
import logging | |
logging.basicConfig(level=logging.INFO, filename='app.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s') | |
logging.info('This will get logged') | |
""" | |
import logging.config | |
logging.basicConfig( | |
level=logging.INFO, | |
format="%(asctime)s [%(levelname)s] %(message)s", | |
handlers=[ | |
logging.FileHandler("log_file.log"), | |
logging.StreamHandler() | |
] | |
) | |
logger = logging.getLogger(__name__) | |
logger.info('message') | |
logger.error('message') | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🤘