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