@@ -2840,6 +2840,69 @@ Use the application logger instead of the PHP logger for logging PHP errors.
28402840When an integer value is used, it also sets the log level. Those integer
28412841values must be the same used in the `error_reporting PHP option `_.
28422842
2843+ This option also accepts a map of PHP errors to log levels:
2844+
2845+ .. configuration-block ::
2846+
2847+ .. code-block :: yaml
2848+
2849+ # config/packages/framework.yaml
2850+ framework :
2851+ php_errors :
2852+ log :
2853+ ' !php/const \E_DEPRECATED ' : !php/const Psr\Log\LogLevel::ERROR
2854+ ' !php/const \E_USER_DEPRECATED ' : !php/const Psr\Log\LogLevel::ERROR
2855+ ' !php/const \E_NOTICE ' : !php/const Psr\Log\LogLevel::ERROR
2856+ ' !php/const \E_USER_NOTICE ' : !php/const Psr\Log\LogLevel::ERROR
2857+ ' !php/const \E_STRICT ' : !php/const Psr\Log\LogLevel::ERROR
2858+ ' !php/const \E_WARNING ' : !php/const Psr\Log\LogLevel::ERROR
2859+ ' !php/const \E_USER_WARNING ' : !php/const Psr\Log\LogLevel::ERROR
2860+ ' !php/const \E_COMPILE_WARNING ' : !php/const Psr\Log\LogLevel::ERROR
2861+ ' !php/const \E_CORE_WARNING ' : !php/const Psr\Log\LogLevel::ERROR
2862+ ' !php/const \E_USER_ERROR ' : !php/const Psr\Log\LogLevel::CRITICAL
2863+ ' !php/const \E_RECOVERABLE_ERROR ' : !php/const Psr\Log\LogLevel::CRITICAL
2864+ ' !php/const \E_COMPILE_ERROR ' : !php/const Psr\Log\LogLevel::CRITICAL
2865+ ' !php/const \E_PARSE ' : !php/const Psr\Log\LogLevel::CRITICAL
2866+ ' !php/const \E_ERROR ' : !php/const Psr\Log\LogLevel::CRITICAL
2867+ ' !php/const \E_CORE_ERROR ' : !php/const Psr\Log\LogLevel::CRITICAL
2868+
2869+ .. code-block :: xml
2870+
2871+ <!-- config/packages/framework.xml -->
2872+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2873+ <container xmlns =" http://symfony.com/schema/dic/services"
2874+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2875+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
2876+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
2877+ https://symfony.com/schema/dic/services/services-1.0.xsd
2878+ http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
2879+
2880+ <framework : config >
2881+ <!-- in XML configuration you cannot use PHP constants as the value of
2882+ the 'type' attribute, which makes this format way less readable.
2883+ Consider using YAML or PHP for this configuration -->
2884+ <framework : log type =" 8" logLevel =" error" />
2885+ <framework : log type =" 2" logLevel =" error" />
2886+ <!-- ... -->
2887+ </framework : config >
2888+ </container >
2889+
2890+ .. code-block :: php
2891+
2892+ // config/packages/framework.php
2893+ use Psr\Log\LogLevel;
2894+ use Symfony\Config\FrameworkConfig;
2895+
2896+ return static function (FrameworkConfig $framework) {
2897+ $framework->phpErrors()->log(\E_DEPRECATED, LogLevel::ERROR);
2898+ $framework->phpErrors()->log(\E_USER_DEPRECATED, LogLevel::ERROR);
2899+ // ...
2900+ };
2901+
2902+ .. versionadded :: 5.3
2903+
2904+ The option to map PHP errors to log levels was introduced in Symfony 5.3.
2905+
28432906throw
28442907.....
28452908
0 commit comments