From 7dc9003dff149e29c0af4d409060d34f9a7775fa Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Wed, 14 Jun 2017 10:57:19 +0430 Subject: [PATCH 1/2] Add `disable-redirect-access-to-syslog` config --- gunicorn/config.py | 18 ++++++++++++++++++ gunicorn/glogging.py | 10 ++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/gunicorn/config.py b/gunicorn/config.py index c0aec1a4b..26ddc0b82 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -1180,6 +1180,19 @@ class AccessLog(Setting): ``'-'`` means log to stdout. """ +class DisableRedirectAccessToSyslog(Setting): + name = "disable_redirect_access_to_syslog" + section = "Logging" + cli = ["--disable-redirect-access-to-syslog"] + validator = validate_bool + action = 'store_true' + default = False + desc = """\ + Disable redirect access logs to syslog. + + .. versionadded:: 19.8 + """ + class AccessLogFormat(Setting): name = "access_log_format" @@ -1342,6 +1355,11 @@ class Syslog(Setting): default = False desc = """\ Send *Gunicorn* logs to syslog. + + .. versionchanged:: 19.8 + + You can now disable sending access logs by using the + :ref:`disable-redirect-access-to-syslog` setting. """ diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index 5f95973f9..a54a31f1d 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -219,9 +219,10 @@ def setup(self, cfg): self._set_syslog_handler( self.error_log, cfg, self.syslog_fmt, "error" ) - self._set_syslog_handler( - self.access_log, cfg, self.syslog_fmt, "access" - ) + if not cfg.disable_redirect_access_to_syslog: + self._set_syslog_handler( + self.access_log, cfg, self.syslog_fmt, "access" + ) if cfg.logconfig: if os.path.exists(cfg.logconfig): @@ -314,7 +315,8 @@ def access(self, resp, req, environ, request_time): for format details """ - if not (self.cfg.accesslog or self.cfg.logconfig or self.cfg.syslog): + if not (self.cfg.accesslog or self.cfg.logconfig or + (self.cfg.syslog and not self.cfg.disable_access_log_redirection)): return # wrap atoms: From 919871d656c9850eb369d03473907b28c485ad7c Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Wed, 14 Jun 2017 11:04:49 +0430 Subject: [PATCH 2/2] Add `disable-redirect-access-to-syslog` documentation. --- docs/source/settings.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/source/settings.rst b/docs/source/settings.rst index 49bf58d4d..12fea6caa 100644 --- a/docs/source/settings.rst +++ b/docs/source/settings.rst @@ -609,6 +609,18 @@ The Access log file to write to. ``'-'`` means log to stdout. +.. _disable-redirect-access-to-syslog: + +disable-redirect-access-to-syslog +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* ``--disable-redirect-access-to-syslog`` +* ``False`` + +Disable redirect access logs to syslog. + +.. versionadded:: 19.8 + .. _access-log-format: access_log_format @@ -746,6 +758,11 @@ syslog Send *Gunicorn* logs to syslog. +.. versionchanged:: 19.8 + + You can now disable sending access logs by using the + :ref:`disable-redirect-access-to-syslog` setting. + .. _syslog-prefix: syslog_prefix