[Tutor] problem with a simple logger with RotatingFileHandler
Daniel
daniel.chaowang at gmail.com
Tue Apr 14 10:49:17 CEST 2009
hi list,
I write a simple logger, which follows the example on
http://docs.python.org/library/logging.html, as this:
def get_logger(log_filename):
my_logger = logging.getLogger("MyLogger")
my_logger.setLevel(logging.debug)
handler = logging.handlers.RotatingFileHandler(log_filename,
maxBytes=1000000, backupCount=5)
my_logger.addHandler(handler)
return my_logger
def test_logger():
logger = get_logger(r"d:\tmp\mylog.txt")
print logger
msg = "repeted message"
for i in range(10000):
logger.info(msg)
if __name__ == '__main__':
test_logger()
but the mylog.txt is empy after running. is there something I missed.
Thanks,
Daniel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090414/7985b8ae/attachment-0001.htm>
More information about the Tutor
mailing list