I\'m having no luck finding any information on setting up syslog logging with Django 1.3 dictionary configuration. The Django documents don\'t cover syslog and the python docum
This works for me (on default debian).
/dev/log
is the secret to ensure there is no attempt to use the network.''
equates to the root logger so will catch most stuffIn settings.py:
LOGGING = {
'version': 1,
'handlers': {
'syslog':{
'address': '/dev/log',
'class': 'logging.handlers.SysLogHandler'
}
},
'loggers': {
'': {
'handlers': ['syslog'],
'level': 'DEBUG',
}
}
}
in the app:
import logging
logging.info("freakout info")
provides:
john:/var/log$ sudo tail -1 user.log
Dec 14 17:15:52 john freakout info
Finally found the answer, modify the configuration in the original question to have the following for 'syslog':
from logging.handlers import SysLogHandler
...
'syslog':{
'level':'DEBUG',
'class': 'logging.handlers.SysLogHandler',
'formatter': 'verbose',
'facility': SysLogHandler.LOG_LOCAL2,
},
...
Warning to future generations: you pretty much have to do it exactly like the above, weird errors happen if you specify the class directly etc.
Update: I've just moved to Amazon Linux (and Django 1.5) and used the following change to the configuration for the 'syslog' section in that environment, note the 'address' argument:
'syslog':{
'level':'DEBUG',
'class': 'logging.handlers.SysLogHandler',
'formatter': 'verbose',
'facility': 'local1',
'address': '/dev/log',
},