From 35884482218932f02c04b5d84a456206990d9b2d Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 8 Jun 2022 18:35:34 +0100 Subject: [PATCH] . --- rad/settings.py | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/rad/settings.py b/rad/settings.py index d0dc1a2c..1979d20c 100644 --- a/rad/settings.py +++ b/rad/settings.py @@ -199,12 +199,51 @@ TAGULOUS_AUTOCOMPLETE_CSS = {"all": ["tagulous/lib/select2-3/select2.css"]} INTERNAL_IPS = ["localhost", "127.0.0.1"] +#LOGGING = { +# "version": 1, +# "disable_existing_loggers": False, +# "incremental": True, +# "root": { +# "level": "DEBUG", +# }, +#} LOGGING = { - "version": 1, - "disable_existing_loggers": False, - "incremental": True, - "root": { - "level": "DEBUG", + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + # Include the default Django email handler for errors + # This is what you'd get without configuring logging at all. + 'mail_admins': { + 'class': 'django.utils.log.AdminEmailHandler', + 'level': 'ERROR', + # But the emails are plain text by default - HTML is nicer + 'include_html': True, + }, + # Log to a text file that can be rotated by logrotate + 'logfile': { + 'class': 'logging.handlers.WatchedFileHandler', + 'filename': '/var/log/django/myapp.log' + }, + }, + 'loggers': { + # Again, default Django configuration to email unhandled exceptions + 'django.request': { + 'handlers': ['mail_admins'], + 'level': 'ERROR', + 'propagate': True, + }, + # Might as well log any errors anywhere else in Django + 'django': { + 'handlers': ['logfile'], + 'level': 'ERROR', + 'propagate': False, + }, + # Your own app - this assumes all your logger names start with "myapp." + 'myapp': { + 'handlers': ['logfile'], + 'level': 'WARNING', # Or maybe INFO or DEBUG + 'propagate': False + }, }, }