I have a django 1.4.2 application logging going to a rotating files. In my settings.py I have:
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
},
},
'handlers': {
'default': {
'level':'DEBUG',
'class':'logging.handlers.RotatingFileHandler',
'filename': '/var/www/html/logs/mylog.log',
'maxBytes': 1024*1024*5, # 5 MB
'backupCount': 5,
'formatter':'standard',
},
'request_handler': {
'level':'DEBUG',
'class':'logging.handlers.RotatingFileHandler',
'filename': '/var/www/html/logs/django_request.log',
'maxBytes': 1024*1024*5, # 5 MB
'backupCount': 5,
'formatter':'standard',
},
},
'loggers': {
'': {
'handlers': ['default'],
'level': 'ERROR',
'propagate': True
},
'django.request': { # Stop SQL debug from logging to main logger
'handlers': ['request_handler'],
'level': 'DEBUG',
'propagate': False
},
}
}
So in the logging directory I see the files:
mc.log
mc.log.1
mc.log.2
mc.log.3
mc.log.4
mc.log.5
When mc.log reach 5M the files are correctly rotated but the new mc.log is created with ownership root.root. Since apache is running under apache user, it cannot access anymore to the files and the application stops working. Any idea why the new log is created with root.root ownership instead of apache.apache?
Thanks