Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Symfony version(s) affected

7.4

Description

Upgrading my project to Symfony 8.0 lead to a lot of broken code. I didnt know why, because I never got any deprecations.
Ive set error_reporting(E_ALL) and used the Monolog log handler to write everything to file.
Nothing pops up.
I've registered the logger via Monolog\ErrorHandler::register($logger).

In the Symfony\Component\Console\Application line 558 (in v7.4) a function called trigger_deprecation() is called which should have notified me, that my code will be broken in 8.0, but I never got it!
Turns out: trigger_deprecation() executes @trigger_error().
The monolog error handle compares the (new) value of error_reporting() to E_USER_DEPRECATED and wont log it to file. Because with the @ the error_reporting() is now set to 4437 (instead of E_ALL) before!

So every deprecation CANT get logged with monolog! They only way to get them to log is NOT using Monolog\ErrorHandler::register($logger), instead use this:

$handler = new ErrorHandler($logger);
$handler->registerErrorHandler(handleOnlyReportedErrors: false);
$handler->registerExceptionHandler();
$handler->registerFatalHandler();

How to reproduce

require_once 'vendor/autoload.php';

$logger = new \Monolog\Logger(
    'logger',
    [new \Monolog\Handler\StreamHandler(__DIR__ . '/error.log', \Monolog\Logger::DEBUG)]
);

// DOES NOT LOG ANYTHING:
\Monolog\ErrorHandler::register($logger);

// INSTEAD USE THIS:
$handler = new \Monolog\ErrorHandler($logger);
$handler->registerErrorHandler(handleOnlyReportedErrors: false);

$application = new \Symfony\Component\Console\Application();
$application->add(new \Symfony\Component\Console\Command\Command('abc'));

Possible Solution

No response

Additional Context

No response

You must be logged in to vote

Replies: 3 comments

Comment options

You need to configure a depreciation channel, see https://github.com/symfony/recipes/blob/main/symfony/monolog-bundle/3.7/config/packages/monolog.yaml as a start

You must be logged in to vote
0 replies
Comment options

you should not register the Monolog ErrorHandler, as this would replace the error handler registered by symfony/error-handler

You must be logged in to vote
0 replies
Comment options

Sorry forgot to say: Im not using the symfony framework. So no bundles etc.

Im using these packages independently:

monolog/monolog                                  3.10.0                                                            Sends your logs to files, sockets, inboxes, databases and various web services
symfony/console                                  7.4.4                                                             Eases the creation of beautiful and testable command line interfaces
symfony/css-selector                             8.0.0                                                             Converts CSS selectors to XPath expressions
symfony/deprecation-contracts                    3.6.0                                                             A generic function and convention to trigger deprecation notices
symfony/event-dispatcher                         8.0.4                                                             Provides tools that allow your application components to communicate with each other by dispatching events and listening to them
symfony/event-dispatcher-contracts               3.6.0                                                             Generic abstractions related to dispatching event
symfony/filesystem                               8.0.1                                                             Provides basic utilities for the filesystem
symfony/ldap                                     8.0.4                                                             Provides a LDAP client for PHP on top of PHP's ldap extension
symfony/mailer                                   8.0.4                                                             Helps sending emails
symfony/mime                                     8.0.5                                                             Allows manipulating MIME messages
symfony/options-resolver                         8.0.0                                                             Provides an improved replacement for the array_replace PHP function
symfony/polyfill-intl-idn                        1.33.0                                                            Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/process                                  8.0.5                                                             Executes commands in sub-processes
symfony/service-contracts                        3.6.1                                                             Generic abstractions related to writing services
symfony/stopwatch                                8.0.0                                                             Provides a way to profile code
symfony/string                                   8.0.4                                                             Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way
symfony/var-exporter                             8.0.0                                                             Allows exporting any serializable PHP data structure to plain PHP code
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #63479 on February 24, 2026 13:44.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.