Skip to content

Added a code example for emailing on 4xx and 5xx errors without 404's #4371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion cookbook/logging/monolog_email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ it is broken down.
handlers:
mail:
type: fingers_crossed
# 500 errors are logged at the critical level
action_level: critical
# to also log 400 level errors (but not 404's):
# action_level: error
# excluded_404:
# - ^/
handler: buffered
buffered:
type: buffer
Expand Down Expand Up @@ -48,6 +53,12 @@ it is broken down.
type="fingers_crossed"
action-level="critical"
handler="buffered"
<!--
To also log 400 level errors (but not 404's):
action-level="error"
And add this child inside this monolog:handler
<monolog:excluded-404>^/</monolog:excluded-404>
-->
/>
<monolog:handler
name="buffered"
Expand Down Expand Up @@ -81,6 +92,11 @@ it is broken down.
'mail' => array(
'type' => 'fingers_crossed',
'action_level' => 'critical',
// to also log 400 level errors (but not 404's):
// 'action_level' => 'error',
// 'excluded_404s' => array(
// '^/',
// ),
'handler' => 'buffered',
),
'buffered' => array(
Expand Down Expand Up @@ -108,7 +124,8 @@ setting means that the output is then passed onto the ``buffered`` handler.
.. tip::

If you want both 400 level and 500 level errors to trigger an email,
set the ``action_level`` to ``error`` instead of ``critical``.
set the ``action_level`` to ``error`` instead of ``critical``. See the
code above for an example.

The ``buffered`` handler simply keeps all the messages for a request and
then passes them onto the nested handler in one go. If you do not use this
Expand Down