yanivk1984
6/30/2019 - 11:16 AM

python logging configuration via code

import logging

logging.basicConfig(
    filename='Debugs/debug.txt',
    level=logging.INFO,
    format='%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S',
)

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
handler = RotatingFileHandler('Debugs/debug.txt', maxBytes=1000000, backupCount=2)
logger.addHandler(handler)