Created
August 25, 2023 19:58
-
-
Save mwestwood/ec60ea723c4edae261ed99e35a793175 to your computer and use it in GitHub Desktop.
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 | |
# Configure logging | |
logging.basicConfig(level=logging.INFO, format='%(message)s') | |
logger = logging.getLogger() | |
# Add a file handler to log to a text file | |
file_handler = logging.FileHandler('output.log') | |
file_handler.setLevel(logging.INFO) | |
file_handler.setFormatter(logging.Formatter('%(asctime)s - %(message)s')) | |
logger.addHandler(file_handler) | |
# Your script code starts here | |
logger.info("This message will be logged to both console and output.log") | |
logger.info("Another message") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment