framework: StreamHandler class not found when logging deprecation warnings
- Laravel Version: 8.80
- PHP Version: 8.1
- Database Driver & Version: mysql 8
Description:
When trying to use deprecation logging feature, some of my endpoint crashes with error 500 and nothing is catched in laravel’s logs. I found this in /var/log/nginx/myproject-error.log
:
[error] 815505#815505: *1186160 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class "Monolog\Handler\StreamHandler" not found in /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:175
Stack trace:
#0 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger()
#1 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get()
#2 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager->driver()
#3 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(101): Illuminate\Log\LogManager->channel()
#4 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(72): Illuminate\Foundation\Bootstrap\HandleExceptions->handleDeprecation()
#5 /home/forge/myproject/vendor...PHP message: PHP Fatal error: Uncaught Error: Class "Monolog\Handler\StreamHandler" not found in /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:175
Stack trace:
#0 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger()
#1 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get()
#2 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager->driver()
#3 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(101): Illuminate\Log\LogManager->channel()
#4 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(72): Illuminate\Foundation\Bootstrap\HandleExceptions->han
It looks pretty similar to https://github.com/laravel/framework/pull/39938
Steps To Reproduce:
in config/logging.php :
'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'channels' => [
...
'php_deprecation_warnings' => [
'driver' => 'single',
'path' => storage_path('logs/php-deprecation-warnings.log'),
],
]
in .env :
LOG_DEPRECATIONS_CHANNEL=php_deprecation_warnings
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 26 (17 by maintainers)
And unfortunately, I can’t reproduce it locally either, so I have no way to inspect what the initial exception is.
Totally agree with you. Only that the config for the emergency logger, in this case, is what is the default in the code any way.
But I’ll add the emergency logger and test.
Hey @JackWH yea, got quite an amount of time into tracking this thing 😅 . Most of the currently relevant information is stowed away in the thread at https://github.com/php/php-src/issues/8164. It just so happens that I posted in there earlier today stating I would try out
8.1.6RC1
. Currently running8.1.6RC1-fpm
in one of the sites in production which as of yet hasn’t gone haywire 🤞 (although it might take a couple of days).I don’t have a way to reproduce this. I propose that we wait a little bit more, until we have other people with the same issue (if any…) and maybe they are able to provide us a way to reproduce this.
Meanwhile, if you are able to understand what’s happening, let me know.
I encountered the same error in our staging environment this morning after upgrading to framework version
v8.83.1
. Could not get it to trigger locally though.Rolling back to
v8.83.0
did not solve it though.monolog versions: 2.3.5
We use
LOG_DEPRECATIONS_CHANNEL=stderr
Stacktrace