Hello all,
I am using logging module for my application to log all debug information. I
configured it create a new log file every day with
"TimedRotatingFileHandler". I display debug message in console as well.
But I didn't see creation of new file. Can someone help me to sort out this
problem. Following is config code:
import logging
from logging.handlers import TimedRotatingFileHandler
Ffilename = os.path.join(dir_path, 'Pyserverlog')
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s -
%(message)s', datefmt='%a, %d %b %Y %H:%M:%S', level = logging.DEBUG,
filename=Ffilename, filemode='w')
logger = logging.getLogger(__name__)
hdlr = TimedRotatingFileHandler(Ffilename, when='midnight')
logger.addHandler(hdlr)
# define a Handler which writes INFO messages or higher to the sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s -
%(message)s')
# tell the handler to use this format
console.setFormatter(formatter)
# add the handler to the root logger
logging.getLogger('').addHandler(console)
--
nambi
--
https://mail.python.org/mailman/listinfo/python-list