Skip to content

Commit ec3a220

Browse files
committed
Updating recommended email settings for monolog
1 parent 41716df commit ec3a220

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

cookbook/logging/monolog_email.rst

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,20 @@ it is broken down.
2525
# action_level: error
2626
# excluded_404s:
2727
# - ^/
28-
handler: buffered
29-
buffered:
30-
type: buffer
28+
handler: deduplicated
29+
deduplicated:
30+
type: deduplication
3131
handler: swift
3232
swift:
3333
type: swift_mailer
3434
from_email: 'error@example.com'
3535
to_email: 'error@example.com'
3636
# or list of recipients
3737
# to_email: ['dev1@example.com', 'dev2@example.com', ...]
38-
subject: An Error Occurred!
38+
subject: 'An Error Occurred! %%message%%'
3939
level: debug
40+
formatter: monolog.formatter.html
41+
content_type: text/html
4042
4143
.. code-block:: xml
4244
@@ -49,33 +51,36 @@ it is broken down.
4951
http://symfony.com/schema/dic/monolog http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
5052
5153
<monolog:config>
52-
<!--
53-
To also log 400 level errors (but not 404's):
54+
<!--
55+
500 errors are logged at the critical level,
56+
to also log 400 level errors (but not 404's):
5457
action-level="error"
5558
And add this child inside this monolog:handler
56-
<monolog:excluded-404>^/</monolog:excluded-404>
59+
<monolog:excluded-404>^/</monolog:excluded-404>
5760
-->
5861
<monolog:handler
5962
name="mail"
6063
type="fingers_crossed"
6164
action-level="critical"
62-
handler="buffered"
65+
handler="deduplicated"
6366
/>
6467
<monolog:handler
65-
name="buffered"
66-
type="buffer"
68+
name="deduplicated"
69+
type="deduplication"
6770
handler="swift"
68-
/>
71+
>
6972
<monolog:handler
7073
name="swift"
7174
type="swift_mailer"
7275
from-email="error@example.com"
73-
subject="An Error Occurred!"
74-
level="debug">
76+
subject="An Error Occurred! %%message%%"
77+
level="debug"
78+
formatter="monolog.formatter.html"
79+
content-type="text/html">
7580
7681
<monolog:to-email>error@example.com</monolog:to-email>
7782
78-
<!-- or multiple to-email elements -->
83+
<!-- or list of recipients -->
7984
<!--
8085
<monolog:to-email>dev1@example.com</monolog:to-email>
8186
<monolog:to-email>dev2@example.com</monolog:to-email>
@@ -92,26 +97,29 @@ it is broken down.
9297
'handlers' => array(
9398
'mail' => array(
9499
'type' => 'fingers_crossed',
100+
// 500 errors are logged at the critical level
95101
'action_level' => 'critical',
96102
// to also log 400 level errors (but not 404's):
97103
// 'action_level' => 'error',
98104
// 'excluded_404s' => array(
99105
// '^/',
100106
// ),
101-
'handler' => 'buffered',
107+
'handler' => 'deduplicated',
102108
),
103-
'buffered' => array(
104-
'type' => 'buffer',
105-
'handler' => 'swift',
109+
'duplicated' => array(
110+
'type' => 'deduplication',
111+
'handler' => 'swift'
106112
),
107113
'swift' => array(
108-
'type' => 'swift_mailer',
109-
'from_email' => 'error@example.com',
110-
'to_email' => 'error@example.com',
114+
'type' => 'swift_mailer',
115+
'from_email' => 'error@example.com',
116+
'to_email' => 'error@example.com',
111117
// or a list of recipients
112118
// 'to_email' => array('dev1@example.com', 'dev2@example.com', ...),
113-
'subject' => 'An Error Occurred!',
114-
'level' => 'debug',
119+
'subject' => 'An Error Occurred! %%message%%',
120+
'level' => 'debug',
121+
'formatter' => 'monolog.formatter.html'
122+
'content_type' => 'text/html'
115123
),
116124
),
117125
));

0 commit comments

Comments
 (0)