From a3b6a01c4b70002fdfe535b4090cdf2153fa6857 Mon Sep 17 00:00:00 2001 From: Shaun Simmons Date: Fri, 28 Jul 2017 16:55:53 -0400 Subject: [PATCH 1/6] Document new Monolog HTTP code exclusion feature --- logging/monolog_exclude_http_codes.rst | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 logging/monolog_exclude_http_codes.rst diff --git a/logging/monolog_exclude_http_codes.rst b/logging/monolog_exclude_http_codes.rst new file mode 100644 index 00000000000..18d61ffd492 --- /dev/null +++ b/logging/monolog_exclude_http_codes.rst @@ -0,0 +1,60 @@ +.. index:: + single: Logging + single: Logging; Exclude HTTP Codes + single: Monolog; Exclude HTTP Codes + +How to Configure Monolog to Exclude Specific HTTP Codes from the Log +=========================================================== + +Sometimes your logs become flooded with unwanted HTTP errors, for example, +403s and 404s. When using a ``fingers_crossed`` handler, you can exclude +logging these HTTP codes based on the MonologBundle configuration: + +.. configuration-block:: + + .. code-block:: yaml + + # app/config/config.yml + monolog: + handlers: + main: + # ... + type: fingers_crossed + handler: ... + excluded_http_codes: + - 403 + - 404 + + .. code-block:: xml + + + + + + + + 403 + 404 + + + + + .. code-block:: php + + // app/config/config.php + $container->loadFromExtension('monolog', array( + 'handlers' => array( + 'main' => array( + // ... + 'type' => 'fingers_crossed', + 'handler' => ..., + 'excluded_http_codes' => array(403, 404), + ), + ), + )); From c9f6ee5ea5735d9ff6528872ade134ebef5616b8 Mon Sep 17 00:00:00 2001 From: Shaun Simmons Date: Fri, 28 Jul 2017 17:07:17 -0400 Subject: [PATCH 2/6] Fix title underline length --- logging/monolog_exclude_http_codes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging/monolog_exclude_http_codes.rst b/logging/monolog_exclude_http_codes.rst index 18d61ffd492..d78b03ea12d 100644 --- a/logging/monolog_exclude_http_codes.rst +++ b/logging/monolog_exclude_http_codes.rst @@ -4,7 +4,7 @@ single: Monolog; Exclude HTTP Codes How to Configure Monolog to Exclude Specific HTTP Codes from the Log -=========================================================== +==================================================================== Sometimes your logs become flooded with unwanted HTTP errors, for example, 403s and 404s. When using a ``fingers_crossed`` handler, you can exclude From 17cb416cea0f3ce59c1e45287aa4cf15537a86c3 Mon Sep 17 00:00:00 2001 From: Shaun Simmons Date: Sun, 18 Feb 2018 05:33:30 -0500 Subject: [PATCH 3/6] Update configuration format to support URL blacklist --- logging/monolog_exclude_http_codes.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/logging/monolog_exclude_http_codes.rst b/logging/monolog_exclude_http_codes.rst index d78b03ea12d..c7c3b6ecebf 100644 --- a/logging/monolog_exclude_http_codes.rst +++ b/logging/monolog_exclude_http_codes.rst @@ -21,9 +21,7 @@ logging these HTTP codes based on the MonologBundle configuration: # ... type: fingers_crossed handler: ... - excluded_http_codes: - - 403 - - 404 + excluded_http_codes: [403, 404, { 400: ['^/foo', '^/bar'] }] .. code-block:: xml @@ -39,8 +37,11 @@ logging these HTTP codes based on the MonologBundle configuration: - 403 - 404 + + ^/foo + ^/bar + + From e19bca2af717612ef23db9361dd3711f0e57335f Mon Sep 17 00:00:00 2001 From: Shaun Simmons Date: Sun, 18 Feb 2018 05:37:26 -0500 Subject: [PATCH 4/6] Fix indentation --- logging/monolog_exclude_http_codes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logging/monolog_exclude_http_codes.rst b/logging/monolog_exclude_http_codes.rst index c7c3b6ecebf..0a0c82ffad6 100644 --- a/logging/monolog_exclude_http_codes.rst +++ b/logging/monolog_exclude_http_codes.rst @@ -38,8 +38,8 @@ logging these HTTP codes based on the MonologBundle configuration: - ^/foo - ^/bar + ^/foo + ^/bar From c8c19f26b1c614a2d6d2939f6fd635dd481592db Mon Sep 17 00:00:00 2001 From: Shaun Simmons Date: Wed, 18 Apr 2018 14:10:27 -0400 Subject: [PATCH 5/6] Update to Symfony 4 paths --- logging/monolog_exclude_http_codes.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/logging/monolog_exclude_http_codes.rst b/logging/monolog_exclude_http_codes.rst index 0a0c82ffad6..44c8479801e 100644 --- a/logging/monolog_exclude_http_codes.rst +++ b/logging/monolog_exclude_http_codes.rst @@ -14,7 +14,7 @@ logging these HTTP codes based on the MonologBundle configuration: .. code-block:: yaml - # app/config/config.yml + # config/packages/prod/monolog.yaml monolog: handlers: main: @@ -25,7 +25,7 @@ logging these HTTP codes based on the MonologBundle configuration: .. code-block:: xml - + loadFromExtension('monolog', array( 'handlers' => array( 'main' => array( From 30cc7d42abdb9aeaa176689d3536237422304fe9 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 15 May 2018 17:12:09 +0200 Subject: [PATCH 6/6] Added the versionadded directive --- logging/monolog_exclude_http_codes.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/logging/monolog_exclude_http_codes.rst b/logging/monolog_exclude_http_codes.rst index 44c8479801e..27984836f4f 100644 --- a/logging/monolog_exclude_http_codes.rst +++ b/logging/monolog_exclude_http_codes.rst @@ -6,6 +6,10 @@ How to Configure Monolog to Exclude Specific HTTP Codes from the Log ==================================================================== +..versionadded:: 4.1 + The ability to exclude log messages based on their status codes was + introduced in Symfony 4.1 and MonologBundle 3.3. + Sometimes your logs become flooded with unwanted HTTP errors, for example, 403s and 404s. When using a ``fingers_crossed`` handler, you can exclude logging these HTTP codes based on the MonologBundle configuration: