-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
StreamHandler class not found when logging deprecation warnings #41035
Comments
@smknstd I will need you to send me the full error output. |
Hello @nunomaduro ! This is all I got unfortunately it seems truncated or something in nginx logs for some reason ... |
Are you running the latest version of monolog? Do you mind upgrading that package? |
I think it is the last version. From composer lock:
|
I encountered the same error in our staging environment this morning after upgrading to framework version Rolling back to monolog versions: 2.3.5 We use Stacktrace
|
@smknstd Do you have Sentry or some other exception handling service? |
Great point ! Yes, we have getsentry/sentry-laravel 2.11.0 |
Can you share the full "logging.php" file? |
This is our <?php
use Monolog\Handler\StreamHandler;
return [
'default' => env('LOG_CHANNEL', 'stderr'),
'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'stderr'),
'channels' => [
// Should be used for docker
'stderr' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'tap' => [
\App\Logging\AddAmznTraceIdContext::class,
\App\Logging\AddRecruiterIdContext::class,
],
'level' => env('LOG_LEVEL', 'debug'),
'with' => [
'stream' => 'php://stderr',
],
],
],
]; |
@hmazter Can't reproduce your issue. But aren't you missing an |
I'd also recommend against modifying the logging.php file like that. It's best that you leave the defaults in place. |
There was no framework/src/Illuminate/Log/LogManager.php Lines 173 to 178 in 7ba34a8
|
@hmazter you should always update config files when upgrading Laravel versions. Tools like Laravel Shift can greatly help with this. |
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. But I'll add the emergency logger and test. |
here is the whole
|
Did a deploy with this config (changed the path for emergency logger since I'm running in docker/AWS ECS and <?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'stderr'),
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => env('LOG_LEVEL', 'critical'),
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => SyslogUdpHandler::class,
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
],
],
// Should be used for docker
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'tap' => [
\App\Logging\AddAmznTraceIdContext::class,
\App\Logging\AddRecruiterIdContext::class,
],
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => sys_get_temp_dir() . '/emergency.log',
],
],
]; And I'm getting this stacktrace
And the exception line is this: framework/src/Illuminate/Log/LogManager.php Line 175 in 29bc877
I'm sorry I don't have more info to work with. |
Wild speculation, bit seems that the first call to So, something breaks during autoload? |
Just a note, I get the same behavior even if I'm removing the calls to Sentry. This is the shorter stack trace that is dumped by the server
|
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. |
Not sure whether to report here in this closed report. But since @nunomaduro waited for other people to respond - and the label on this issue is "needs more info" - I'll add my finding. we're running Laravel in kubernetes in production and got around 90k of errors in sentry a few hours ago. Most of these errors (but not solely) occurred on the
Running:
and our `logging.php`declare(strict_types=1);use Modules\Core\Enum\LogChannel; return [
]; There's little more information why this error would have occurred. Since the pods have been killed by kubernetes any other logs which might have ended up in *fyi: here the same error is reported: #41070 with the notice |
And a few of the stacktraces:
Trace 1
Symfony\Component\ErrorHandler\Error\FatalError: Uncaught Error: Class "Illuminate\Log\Logger" not found in /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:180
Stack trace:
#0 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger()
#1 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get('deprecations')
#2 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager->driver('deprecations')
#3 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(104): Illuminate\Log\LogManager->channel('deprecations')
#4 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(71): Illuminate\Foundation\Bootstrap\HandleExceptions->handleDeprecation('Return type of ...', '/srv/app/vendor...', 866)
#5 /srv/app/vendor/composer/ClassLoader.php(571): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return type of ...', '/srv/app/vendor...', 866)
#6 /srv/app/vendor/composer/ClassLoader.php(571): include('/srv/app/vendor...')
#7 /srv/app/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/srv/app/vendor...')
#8 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): Composer\Autoload\ClassLoader->loadClass('Illuminate\\Log\\...')
#9 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger()
#10 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get('stack')
#11 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager->driver()
#12 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(252): Illuminate\Log\LogManager->error('Class "Illumina...', Array)
#13 /srv/app/app/Exceptions/Handler.php(88): Illuminate\Foundation\Exceptions\Handler->report(Object(Error))
#14 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(165): App\Exceptions\Handler->report(Object(Error))
#15 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#16 {main}
thrown
#0 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): null
Trace 2
Error: Class "Illuminate\Log\Logger" not found
#17 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): Illuminate\Log\LogManager::createEmergencyLogger
#16 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get
#15 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver
#14 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager::channel
#13 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(104): Illuminate\Foundation\Bootstrap\HandleExceptions::handleDeprecation
#12 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(71): Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
#11 /vendor/composer/ClassLoader.php(571): include
#10 /vendor/composer/ClassLoader.php(571): Composer\Autoload\includeFile
#9 /vendor/composer/ClassLoader.php(428): Composer\Autoload\ClassLoader::loadClass
#8 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): Illuminate\Log\LogManager::createEmergencyLogger
#7 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get
#6 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver
#5 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager::error
#4 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(252): Illuminate\Foundation\Exceptions\Handler::report
#3 /app/Exceptions/Handler.php(88): App\Exceptions\Handler::report
#2 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(415): Illuminate\Foundation\Http\Kernel::reportException
#1 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(113): Illuminate\Foundation\Http\Kernel::handle
#0 /public/index.php(38): null
Trace 3
Error: Class "Illuminate\Log\Logger" not found
#42 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): Illuminate\Log\LogManager::createEmergencyLogger
#41 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get
#40 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver
#39 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager::channel
#38 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(104): Illuminate\Foundation\Bootstrap\HandleExceptions::handleDeprecation
#37 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(71): Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
#36 /vendor/composer/ClassLoader.php(571): include
#35 /vendor/composer/ClassLoader.php(571): Composer\Autoload\includeFile
#34 /vendor/composer/ClassLoader.php(428): Composer\Autoload\ClassLoader::loadClass
#33 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): Illuminate\Log\LogManager::createEmergencyLogger
#32 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get
#31 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver
#30 /vendor/maximum/request-tracking/src/Code/Providers/RequestTrackingServiceProvider.php(32): Maximum\RequestTracking\Providers\RequestTrackingServiceProvider::Maximum\RequestTracking\Providers\{closure}
#29 /vendor/laravel/framework/src/Illuminate/Container/Container.php(873): Illuminate\Container\Container::build
#28 /vendor/laravel/framework/src/Illuminate/Container/Container.php(758): Illuminate\Container\Container::resolve
#27 /vendor/laravel/framework/src/Illuminate/Foundation/Application.php(851): Illuminate\Foundation\Application::resolve
#26 /vendor/laravel/framework/src/Illuminate/Container/Container.php(694): Illuminate\Container\Container::make
#25 /vendor/laravel/framework/src/Illuminate/Foundation/Application.php(836): Illuminate\Foundation\Application::make
#24 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(156): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#23 /vendor/maximum/request-tracking/src/Code/Http/Middleware/RequestId.php(45): Maximum\RequestTracking\Http\Middleware\RequestId::handle
#22 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#21 /vendor/laravel-modules/core/src/Code/Http/Middleware/ErrorReporterContext.php(25): Modules\Core\Http\Middleware\ErrorReporterContext::handle
#20 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#19 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline::then
#18 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(723): Illuminate\Routing\Router::runRouteWithinStack
#17 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(698): Illuminate\Routing\Router::runRoute
#16 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\Routing\Router::dispatchToRoute
#15 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(651): Illuminate\Routing\Router::dispatch
#14 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\Foundation\Http\Kernel::Illuminate\Foundation\Http\{closure}
#13 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#12 /vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestIpMiddleware.php(45): Sentry\Laravel\Http\SetRequestIpMiddleware::handle
#11 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#10 /vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestMiddleware.php(42): Sentry\Laravel\Http\SetRequestMiddleware::handle
#9 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#8 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Foundation\Http\Middleware\TransformsRequest::handle
#7 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TrimStrings::handle
#6 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#5 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Foundation\Http\Middleware\ValidatePostSize::handle
#4 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#3 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline::then
#2 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Foundation\Http\Kernel::sendRequestThroughRouter
#1 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel::handle
#0 /public/index.php(38): null
Trace 4
Symfony\Component\ErrorHandler\Error\FatalError: Uncaught Error: Class "Monolog\Handler\StreamHandler" not found in /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:175
Stack trace:
#0 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger()
#1 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get('deprecations')
#2 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager->driver('deprecations')
#3 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(104): Illuminate\Log\LogManager->channel('deprecations')
#4 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(71): Illuminate\Foundation\Bootstrap\HandleExceptions->handleDeprecation('Return type of ...', '/srv/app/vendor...', 866)
#5 /srv/app/vendor/composer/ClassLoader.php(571): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return type of ...', '/srv/app/vendor...', 866)
#6 /srv/app/vendor/composer/ClassLoader.php(571): include('/srv/app/vendor...')
#7 /srv/app/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/srv/app/vendor...')
#8 /srv/app/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php(26): Composer\Autoload\ClassLoader->loadClass('Monolog\\Handler...')
#9 /srv/app/vendor/composer/ClassLoader.php(571): include('/srv/app/vendor...')
#10 /srv/app/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/srv/app/vendor...')
#11 /srv/app/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(27): Composer\Autoload\ClassLoader->loadClass('Monolog\\Handler...')
#12 /srv/app/vendor/composer/ClassLoader.php(571): include('/srv/app/vendor...')
#13 /srv/app/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/srv/app/vendor...')
#14 /srv/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php(26): Composer\Autoload\ClassLoader->loadClass('Monolog\\Handler...')
#15 /srv/app/vendor/composer/ClassLoader.php(571): include('/srv/app/vendor...')
#16 /srv/app/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/srv/app/vendor...')
#17 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(175): Composer\Autoload\ClassLoader->loadClass('Monolog\\Handler...')
#18 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger()
#19 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get('stack')
#20 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager->driver()
#21 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(252): Illuminate\Log\LogManager->error('Class "Monolog\\...', Array)
#22 /srv/app/app/Exceptions/Handler.php(88): Illuminate\Foundation\Exceptions\Handler->report(Object(Error))
#23 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(165): App\Exceptions\Handler->report(Object(Error))
#24 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#25 {main}
thrown
#0 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(175): null
|
Is there anyone with more information regarding this? we're burning through hundreds of thousand of errors in Sentry, effectively nuking our budget. So far there's absolutely no indication what might cause this behaviour. But some (but not all) sites we deploy with a release containing php 8.1, that site also starts generating numerous errors within one hour 72.000 errors occurred from one single application on an api endpoint solely returning a static json response with this stacktrace:
|
It seems to be related to a bug in php's opcache: php/php-src#8164 Will leave a comment there tomorrow |
Hey @Levivb, I've been chasing my tail trying to solve this same issue for 4 days now. Seen a few of your comments elsewhere about this, sure has been a fun one to debug 🙃 Did you have any luck trying this with 8.1.6 RC1? For anyone else who comes across this, it's definitely a PHP opcache bug — I've stumbled across 5 or 6 different discussions from various PHP projects all reporting similar issues, nobody seems able to solve it, but all the clues point back to the opcache. I had no idea what the error even was at first, as no logs were being written (emergency logger unavailable due to the faulty opcache resolution). I only found out after installing New Relic which was able to hook in at a lower level (though their telemetry client seems to be affected by this for many people too: newrelic/newrelic-php-agent#387 ) Supposedly PHP 8.1.6 fixes this via php/php-src#8297 — I think it's due to be released properly on May 12th. @nunomaduro — hopefully 8.1.6 can be made available as a patch upgrade on Laravel Forge ASAP once released? Not sure how long minor versions normally take to become available, but it would be much appreciated 🤞 Thank you! |
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 php/php-src#8164. It just so happens that I posted in there earlier today stating I would try out |
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
:It looks pretty similar to #39938
Steps To Reproduce:
in config/logging.php :
in .env :
The text was updated successfully, but these errors were encountered: