I am using the django 1.3 logging function and trying to implement a timedrotatingfilehandler to rotate logs every hour. The logger works with the ability to rotate every hour, but it seems that during each log request it truncates the file. The file has only the last message written. This is a problem in the django handler or I am missing somewhere. Registration Dictionary below:
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format' : "%(asctime)s:%(pathname)s:%(lineno)s: %(message)s",
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
},
'handlers': {
'logfile': {
'level':'DEBUG',
'class':'logging.handlers.TimedRotatingFileHandler',
'filename': "/tmp/log1.log",
'when' : 'hour',
'interval' : 0,
'formatter': 'standard',
},
},
'loggers': {
'collection': {
'handlers': ['logfile'],
'level': 'DEBUG',
},
}
}
Please note: when the interval is set to 1, the log does not rotate. Is this a bug in django?
source
share