sblum / exception-enricher
Enriches exceptions with additional information.
Package info
github.com/sblum/symfony-exception-enricher
Type:symfony-bundle
pkg:composer/sblum/exception-enricher
Requires
- php: >=8.3
- monolog/monolog: ^3.0
- symfony/config: ^6.4 || ^7.4 || ^8.1
- symfony/dependency-injection: ^6.4 || ^7.4 || ^8.1
- symfony/http-foundation: ^6.4 || ^7.4 || ^8.1
- symfony/polyfill-mbstring: ^1.31
- symfony/security-bundle: ^6.4 || ^7.4 || ^8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^v3.11
- phpunit/phpunit: ^9.6
- symfony/phpunit-bridge: ^6.4 || ^7.4 || ^8.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-18 16:53:06 UTC
README
Symfony bundle which enriches exceptions with some additional information like the request URL, the logged in user's name etc.
Requirements
- PHP 8.3 or greater
- Symfony 6.4, 7.4 or 8.1 (Symfony 8 needs PHP 8.4)
- Monolog v2 for version 1.x, v3 for version 2.x
Installation
-
Require the bundle with Composer:
composer require sblum/exception-enricher
-
If not already happened automatically, enable the bundle in
config/bundles.phpby adding it to the array:ExceptionEnricher\ExceptionEnricherBundle::class => ['all' => true],
What gets logged
Every log record gets these extra fields, as far as they are available:
| Field | Content |
|---|---|
request_uri |
method and URI, e.g. POST /api/upload |
request_user_agent |
the User-Agent header |
request_ip |
client IP of the main request |
session_id |
ID of the current session |
username |
identifier of the logged-in user |
request_post_data |
POST data, only for records of level WARNING and above |
request_post_data contains the serialized form fields, or else the request body. To keep a single request from filling the log (e.g. a file upload) and to keep credentials out of it:
- it is cut off after 2048 characters, with a note of the full length (
… [truncated, 7340080 characters]) - secret words are
password,passwd,secret,token,jwt,authorization,apikey,api_keyandcredential(case-insensitive) - form fields, JSON bodies (also with a byte order mark) and urlencoded bodies are masked field by field, also nested: the value of a field whose name contains a secret word becomes
***, as a whole, also when it is a list or an object. A field name that contains a secret word but isn't a plain name (e.g. a JSON document that form parsing turned into a field name) becomes***, too. JSON keeps its shape, and a body without secrets is logged exactly as sent. - a body that looks like JSON but can't be decoded (broken, or nested too deeply) or encoded again is left out:
[JSON body omitted: it could not be decoded to mask secrets, N characters] - any other body (XML, plain text, …) can't be masked reliably: it is logged as it is when it contains no secret word, and left out otherwise:
[Body omitted: it may contain secrets that can't be masked, N characters]
Query strings are part of request_uri and are not masked; don't pass secrets in URLs.