44How to Configure Monolog to Email Errors
55========================================
66
7- .. caution ::
7+ .. versionadded :: 3.6
88
9- This feature is not compatible yet with the new :doc: `Symfony mailer </mailer >`,
10- so it requires using SwiftMailer.
9+ Support for emailing errors using :doc: `Symfony mailer </mailer >` was added in MonologBundle 3.6.
1110
1211`Monolog `_ can be configured to send an email when an error occurs within an
1312application. The configuration for this requires a few nested handlers
@@ -33,9 +32,9 @@ it is broken down.
3332 handler : deduplicated
3433 deduplicated :
3534 type : deduplication
36- handler : swift
37- swift :
38- type : swift_mailer
35+ handler : symfony_mailer
36+ symfony_mailer :
37+ type : symfony_mailer
3938 from_email : ' error@example.com'
4039 to_email : ' error@example.com'
4140 # or list of recipients
@@ -73,11 +72,11 @@ it is broken down.
7372 <monolog : handler
7473 name =" deduplicated"
7574 type =" deduplication"
76- handler =" swift "
75+ handler =" symfony_mailer "
7776 />
7877 <monolog : handler
79- name =" swift "
80- type =" swift_mailer "
78+ name =" symfony_mailer "
79+ type =" symfony_mailer "
8180 from-email =" error@example.com"
8281 subject =" An Error Occurred! %%message%%"
8382 level =" debug"
@@ -114,10 +113,10 @@ it is broken down.
114113 ],
115114 'deduplicated' => [
116115 'type' => 'deduplication',
117- 'handler' => 'swift ',
116+ 'handler' => 'symfony_mailer ',
118117 ],
119- 'swift ' => [
120- 'type' => 'swift_mailer ',
118+ 'symfony_mailer ' => [
119+ 'type' => 'symfony_mailer ',
121120 'from_email' => 'error@example.com',
122121 'to_email' => 'error@example.com',
123122 // or a list of recipients
@@ -162,7 +161,7 @@ You can adjust the time period using the ``time`` option:
162161 type : deduplication
163162 # the time in seconds during which duplicate entries are discarded (default: 60)
164163 time : 10
165- handler : swift
164+ handler : symfony_mailer
166165
167166 .. code-block :: xml
168167
@@ -172,7 +171,7 @@ You can adjust the time period using the ``time`` option:
172171 <monolog : handler name =" deduplicated"
173172 type =" deduplication"
174173 time =" 10"
175- handler =" swift " />
174+ handler =" symfony_mailer " />
176175
177176 .. code-block :: php
178177
@@ -184,12 +183,12 @@ You can adjust the time period using the ``time`` option:
184183 'type' => 'deduplication',
185184 // the time in seconds during which duplicate entries are discarded (default: 60)
186185 'time' => 10,
187- 'handler' => 'swift ',
186+ 'handler' => 'symfony_mailer ',
188187 ],
189188 ],
190189 ]);
191190
192- The messages are then passed to the ``swift `` handler. This is the handler that
191+ The messages are then passed to the ``symfony_mailer `` handler. This is the handler that
193192actually deals with emailing you the error. The settings for this are
194193straightforward, the to and from addresses, the formatter, the content type
195194and the subject.
@@ -217,9 +216,9 @@ get logged on the server as well as the emails being sent:
217216 level : debug
218217 deduplicated :
219218 type : deduplication
220- handler : swift
221- swift :
222- type : swift_mailer
219+ handler : symfony_mailer
220+ symfony_mailer :
221+ type : symfony_mailer
223222 from_email : ' error@example.com'
224223 to_email : ' error@example.com'
225224 subject : ' An Error Occurred! %%message%%'
@@ -259,11 +258,11 @@ get logged on the server as well as the emails being sent:
259258 <monolog : handler
260259 name =" deduplicated"
261260 type =" deduplication"
262- handler =" swift "
261+ handler =" symfony_mailer "
263262 />
264263 <monolog : handler
265- name =" swift "
266- type =" swift_mailer "
264+ name =" symfony_mailer "
265+ type =" symfony_mailer "
267266 from-email =" error@example.com"
268267 subject =" An Error Occurred! %%message%%"
269268 level =" debug"
@@ -303,10 +302,10 @@ get logged on the server as well as the emails being sent:
303302 ],
304303 'deduplicated' => [
305304 'type' => 'deduplication',
306- 'handler' => 'swift ',
305+ 'handler' => 'symfony_mailer ',
307306 ],
308- 'swift ' => [
309- 'type' => 'swift_mailer ',
307+ 'symfony_mailer ' => [
308+ 'type' => 'symfony_mailer ',
310309 'from_email' => 'error@example.com',
311310 'to_email' => 'error@example.com',
312311 // or a list of recipients
0 commit comments