Created
January 30, 2015 20:39
-
-
Save Calzzetta/dc0985ae8f62888d8e5d to your computer and use it in GitHub Desktop.
Logging with TimedRotatingFileHandler
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
from logging.handlers import TimedRotatingFileHandler | |
import logging | |
logHandler = TimedRotatingFileHandler('file_name.log', when="midnight") | |
logFormatter = logging.Formatter('%(asctime)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S') | |
logHandler.setFormatter(logFormatter) | |
logger = logging.getLogger('time_rotate_logger') | |
logger.addHandler(logHandler) | |
logger.setLevel(logging.DEBUG) | |
logger.debug('Running...') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment