It is possible to configure Django to output log to a local or remote syslog service. This configuration uses the python builtin SysLogHandler.
from logging.handlers import SysLogHandler
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format' : "[YOUR PROJECT NAME] [%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt' : "%d/%b/%Y %H:%M:%S"
}
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
'syslog': {
'class': 'logging.handlers.SysLogHandler',
'formatter': 'standard',
'facility': 'user',
# uncomment next line if rsyslog works with unix socket only (UDP reception disabled)
#'address': '/dev/log'
}
},
'loggers': {
'django':{
'handlers': ['syslog'],
'level': 'INFO',
'disabled': False,
'propagate': True
}
}
}
# loggers for my apps, uses INSTALLED_APPS in settings
# each app must have a configured logger
# level can be changed as desired: DEBUG, INFO, WARNING...
MY_LOGGERS = {}
for app in INSTALLED_APPS:
MY_LOGGERS[app] = {
'handlers': ['syslog'],
'level': 'DEBUG',
'propagate': True,
}
LOGGING['loggers'].update(MY_LOGGERS)