Created
September 6, 2019 06:13
-
-
Save pgcd/34540220f46ad214940f00088598f34f to your computer and use it in GitHub Desktop.
Django Logging setup to log directly to papertrail (syslog)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
hostname = socket.gethostname() | |
PAPERTRAIL_HOST = 'logsN.papertrailapp.com' | |
PAPERTRAIL_PORT = 'XXXXX' | |
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
'handlers': { | |
'SysLog': { | |
'level': 'INFO', | |
'class': 'logging.handlers.SysLogHandler', | |
'formatter': 'simple', | |
'address': (PAPERTRAIL_HOST, PAPERTRAIL_PORT), | |
}, | |
}, | |
'formatters': { | |
'simple': { | |
'format': f'%(asctime)s {hostname} %(name)s: %(levelname)s %(module)s %(message)s', | |
'datefmt': '%Y-%m-%dT%H:%M:%S', | |
}, | |
}, | |
'loggers': { | |
'django': { | |
'handlers': ['SysLog'], | |
'level': 'INFO', | |
'propagate': True, | |
}, | |
'app-logger': { | |
'handlers': ['SysLog'], | |
'level': 'CRITICAL', | |
'propagate': True, | |
}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment