Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a3b6a01

Browse filesBrowse files
committed
Document new Monolog HTTP code exclusion feature
1 parent f8e84ec commit a3b6a01
Copy full SHA for a3b6a01

File tree

1 file changed

+60
-0
lines changed
Filter options

1 file changed

+60
-0
lines changed
+60Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
.. index::
2+
single: Logging
3+
single: Logging; Exclude HTTP Codes
4+
single: Monolog; Exclude HTTP Codes
5+
6+
How to Configure Monolog to Exclude Specific HTTP Codes from the Log
7+
===========================================================
8+
9+
Sometimes your logs become flooded with unwanted HTTP errors, for example,
10+
403s and 404s. When using a ``fingers_crossed`` handler, you can exclude
11+
logging these HTTP codes based on the MonologBundle configuration:
12+
13+
.. configuration-block::
14+
15+
.. code-block:: yaml
16+
17+
# app/config/config.yml
18+
monolog:
19+
handlers:
20+
main:
21+
# ...
22+
type: fingers_crossed
23+
handler: ...
24+
excluded_http_codes:
25+
- 403
26+
- 404
27+
28+
.. code-block:: xml
29+
30+
<!-- app/config/config.xml -->
31+
<container xmlns="http://symfony.com/schema/dic/services"
32+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33+
xmlns:monolog="http://symfony.com/schema/dic/monolog"
34+
xsi:schemaLocation="http://symfony.com/schema/dic/services
35+
http://symfony.com/schema/dic/services/services-1.0.xsd
36+
http://symfony.com/schema/dic/monolog
37+
http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
38+
39+
<monolog:config>
40+
<monolog:handler type="fingers_crossed" name="main" handler="...">
41+
<!-- ... -->
42+
<monolog:excluded-http-code>403</monolog:excluded-http-code>
43+
<monolog:excluded-http-code>404</monolog:excluded-http-code>
44+
</monolog:handler>
45+
</monolog:config>
46+
</container>
47+
48+
.. code-block:: php
49+
50+
// app/config/config.php
51+
$container->loadFromExtension('monolog', array(
52+
'handlers' => array(
53+
'main' => array(
54+
// ...
55+
'type' => 'fingers_crossed',
56+
'handler' => ...,
57+
'excluded_http_codes' => array(403, 404),
58+
),
59+
),
60+
));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.