-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Deprecated error are logged on production #26267
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
Comments
the reporting level affects PHP log system, but what you show here are Symfony logs, which are not affected by the error_reporting level. |
Note that you should always silence your deprecations., adding a |
What do you mean? When you call a trigger error, you have to set a PHP error level. Why Here is my production configuration: monolog:
handlers:
# Buffer the logs. Use them only on errors.
main:
type: fingers_crossed
action_level: error
handler: buffer
# @see https://github.com/symfony/symfony/pull/23707
activation_strategy: AppBundle\Monolog\Handler\FingersCrossed\HttpExcludeActivationStrategy
channels: ['!nexy_crypt']
console:
type: console
process_psr_3_messages: false
# Buffer the logs before send it. This is useful for async notification.
buffer:
type: buffer
handler: bridge
bridge:
type: group
members: [file, mail, slack]
file:
type: rotating_file
max_files: 12
date_format: 'Y-m'
path: '%kernel.logs_dir%/%kernel.environment%.log'
level: debug
mail:
type: swift_mailer
from_email: noreply@domain.com
to_email: sullivan@domain.com
subject: App error
level: debug
slack:
type: slackwebhook
webhook_url: '%slack_endpoint%'
channel: '#errors'
level: error
include_extra: true
Well, maybe. But this is not the issue. It's just a sample, I have a bench of deprecation errors thrown by vendor libraries and Symfony itself, like this one:
|
Ok I foudn why I have the deprecated, I have this part on the framework:
php_errors:
log: true But that still does not make sense to me. PHP errors should be logged respecting the error_reporting level of it, am I wrong? If I remove it, I indeed don't have the deprecation, but not event the other level like warnings. |
The problem is caused by this code part: symfony/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php Lines 55 to 56 in c12c078
In a nutshell, if no error level is provided, it will take So I think we have two issues here:
What do you think? TIP: Here is a workaround using the compiler pass: /**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$container->getDefinition('debug.debug_handlers_listener')
->replaceArgument(2, error_reporting());
} |
That could be a good way of handling it, we have to look if it's possible to use the +1. |
error_reporting() holds a runtime value. It should not be used to configure a service/event. |
On this particular case (PHP error logging on Symfony log), I don't see why it should not be used. 🤔
In any case, we just can't change it from the configuration for now. |
I would not recommend to configure the logged errors based on runtime configuration. e.g. error_reporting() goes to zero just with an But I understand you'd like to configure the 3rd argument of "debug.debug_handlers_listener". |
If I can configure error level for reporting, with runtime value or not, I'm fine with it. 👍 |
…a log level (Simperfit) This PR was merged into the 4.1-dev branch. Discussion ---------- [FrameworkBundle] framework.php_errors.log now accept a log level | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #26267 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | todo <!-- required for new features --> We are testing that `framework.php_errors.log` is either a bool or an int (set the value of the log level you want). This fixes #26267, so it gives a way to not log some level on production. Commits ------- 664f821 [FrameworkBundle] framework.php_errors.log now accept a log level
That likely stemmed from the framework bundle flex recipe which makes me wonder if it really should be the default. It bit us when we moved to latest Symfony and hundreds of deprecation logs started appearing in the logs for every single request. The performance was terrible. Moreover, according to the framework bundle reference, the default option should always reflect the debug mode option. cc @fabpot |
For now disabled the framework php_erros log property to false. And setting the monolog logger to log notices and upwards. Only when an error occurs.
In my case My solution after upgrade an old project from SF 3.4 to 4.4: Disable LoggerDataCollector :
Exclude php channel from your monolog handlers :
Transform instantly hundreds of deprecations to zero. |
@acantepie filtering out a specific channel / level in monolog is a workaround imho, as there is no 'nice' way to specifically target 'only php E_USER_DEPRECATED' errors. Your configuration will happily hide away eg. warnings generated by using The commit referenced above seems a better solution, assuming that it works ;-) |
ps: I managed to get this monolog config working, on Sf 3, to filter as little as possible besides E_USER_DEPRECATED:
|
I have a
env.php
file with the following line to set the error reporting level:This file is dumped on the composer autoload thanks to this configuration:
And of course, the
composer dump
is called with--no-dev
on the production server.Currently, if a exception is thrown on production and deprecated error are triggered, they are logged on the production log file.
So I start with this tiny test:
And here is the result:
It works. The deprecated error is ignored and the error_reporting value is
6143
.First, we can supposed the error_reporting is changed later. So I tried with this simple controller action:
After a call of this action, I have the following log:
As you can see, both deprecation and error are logged and the error_reporting value is still the same:
6143
This is why I'm thinking about a bug, because the error reporting level does not change so the deprecation should not be reported.
If you think it is not, I'm curious to know what is the issue. 😄
The text was updated successfully, but these errors were encountered: