Skip to content

Commit

Permalink
feature #4371 Added a code example for emailing on 4xx and 5xx errors…
Browse files Browse the repository at this point in the history
… without 404's (weaverryan)

This PR was merged into the 2.3 branch.

Discussion
----------

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

Hi guys!

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | no
| Applies to    | 2.3+
| Fixed tickets | --

I thought this is useful, because this is how I actually set this up (I *do* want 403 errors emailed, for example, but definitely not all the 404 garbage).

Thanks!

Commits
-------

ba323de Added a code example for emailing on 4xx and 5xx errors without 404's
  • Loading branch information
weaverryan committed Oct 26, 2014
2 parents 3e8aa59 + ba323de commit c10e9c1
Showing 1 changed file with 18 additions and 1 deletion.
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

0 comments on commit c10e9c1

Please sign in to comment.