Reputation: 21503
I'm trying to write to a logger in Django. I've got at the beginning of the views.py
file:
import logging
logger = logging.getLogger('wm')
and later make calls to
logger.debug('message')
In my settings.py
file, I have defined
LOGGING = {
'formatters': {
'medium': {
'format': '[%(username)s] %(levelname)s %(asctime)s: %(message)s'
}
},
'handlers': {
'wmlogfile': {
'class': 'logging.handlers.RotatingFileHandler',
'filename': '/var/log/django/wm.log',
'level':'DEBUG',
'maxBytes': 1024*1024, # 5 MB
'backupCount': 5,
'formatter': 'medium',
},
},
'loggers': {
'wm': {
'handlers': ['wmlogfile'],
'level': 'DEBUG',
'propagate': False,
}
}
}
At first, I was getting 500 errors because the file didn't exist, and then because the permission was denied. I manually created the file and set the permissions to 777, and the app runs, but I get no output in the log file.
What have I done wrong?
Upvotes: 2
Views: 1838
Reputation: 99480
Try setting disable_existing_loggers
to False
as per the example here.
Upvotes: 2