From 8e0974c688d7938742bbd75fc72dd5f15b4244da Mon Sep 17 00:00:00 2001 From: Chris Church Date: Mon, 15 Jul 2013 14:26:57 -0400 Subject: [PATCH] Enabled syslog by default for all 500 errors. --- app_setup/templates/local_settings.py.j2 | 18 ++++++++++++++++++ awx/settings/defaults.py | 2 +- awx/settings/local_settings.py.example | 18 ++++++++++++++++++ config/deb/settings.py | 10 ++++++++-- config/rpm/settings.py | 1 + 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/app_setup/templates/local_settings.py.j2 b/app_setup/templates/local_settings.py.j2 index c9fada42f2..4e1d9e6cc8 100644 --- a/app_setup/templates/local_settings.py.j2 +++ b/app_setup/templates/local_settings.py.j2 @@ -85,3 +85,21 @@ DEFAULT_FROM_EMAIL = 'webmaster@localhost' # Subject-line prefix for email messages send with django.core.mail.mail_admins # or ...mail_managers. Make sure to include the trailing space. EMAIL_SUBJECT_PREFIX = '[AWX] ' + +# Enable logging to syslog. Setting level to ERROR captures 500 errors, +# WARNING also logs 4xx responses. +LOGGING['handlers']['syslog'] = { + 'level': 'WARNING', + 'filters': [], + 'class': 'logging.handlers.SysLogHandler', + 'address': '/dev/log', + 'facility': 'local0', + 'formatter': 'simple', +} + +# Enable the following lines to also log to a file. +#LOGGING['handlers']['file'] = { +# 'class': 'logging.FileHandler', +# 'filename': os.path.join(BASE_DIR, 'awx.log'), +# 'formatter': 'simple', +#} diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index d7452e56a6..7dbd7a731d 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -281,7 +281,7 @@ LOGGING = { 'formatter': 'simple', }, 'syslog': { - 'level': 'ERROR', + 'level': 'WARNING', 'filters': ['require_debug_false'], 'class': 'django.utils.log.NullHandler', 'formatter': 'simple', diff --git a/awx/settings/local_settings.py.example b/awx/settings/local_settings.py.example index 2b03e6b5d6..99bbf8058d 100644 --- a/awx/settings/local_settings.py.example +++ b/awx/settings/local_settings.py.example @@ -87,3 +87,21 @@ DEFAULT_FROM_EMAIL = 'webmaster@localhost' # Subject-line prefix for email messages send with django.core.mail.mail_admins # or ...mail_managers. Make sure to include the trailing space. EMAIL_SUBJECT_PREFIX = '[AWX] ' + +# Enable logging to syslog. Setting level to ERROR captures 500 errors, +# WARNING also logs 4xx responses. +LOGGING['handlers']['syslog'] = { + 'level': 'WARNING', + 'filters': [], + 'class': 'logging.handlers.SysLogHandler', + 'address': '/dev/log', + 'facility': 'local0', + 'formatter': 'simple', +} + +# Enable the following lines to also log to a file. +#LOGGING['handlers']['file'] = { +# 'class': 'logging.FileHandler', +# 'filename': os.path.join(BASE_DIR, 'awx.log'), +# 'formatter': 'simple', +#} diff --git a/config/deb/settings.py b/config/deb/settings.py index 1b020775d9..f1f58153c4 100644 --- a/config/deb/settings.py +++ b/config/deb/settings.py @@ -32,8 +32,14 @@ SECRET_KEY = file('/etc/awx/SECRET_KEY', 'rb').read().strip() ALLOWED_HOSTS = ['*'] -LOGGING = { - 'version': 1, +LOGGING['handlers']['syslog'] = { + # ERROR captures 500 errors, WARNING also logs 4xx responses. + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'logging.handlers.SysLogHandler', + 'address': '/dev/log', + 'facility': 'local0', + 'formatter': 'simple', } SERVER_EMAIL = 'root@localhost' diff --git a/config/rpm/settings.py b/config/rpm/settings.py index ce0d2c5e16..f1f58153c4 100644 --- a/config/rpm/settings.py +++ b/config/rpm/settings.py @@ -33,6 +33,7 @@ SECRET_KEY = file('/etc/awx/SECRET_KEY', 'rb').read().strip() ALLOWED_HOSTS = ['*'] LOGGING['handlers']['syslog'] = { + # ERROR captures 500 errors, WARNING also logs 4xx responses. 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'logging.handlers.SysLogHandler',