I used Monolog Channel with NullHandler on Laravel 5.8. It is worked fine.
But Laravel 6.0 throw following exception.
[2019-09-18 09:59:05] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (Error(code: 0): Call to undefined method Monolog\\Handler\\NullHandler::setFormatter() at /vagrant/server/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:376)
[stacktrace]
#0 /vagrant/server/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(347): Illuminate\\Log\\LogManager->prepareHandler(Object(Monolog\\Handler\\NullHandler), Array)
#1 /vagrant/server/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(185): Illuminate\\Log\\LogManager->createMonologDriver(Array)
I guess it is Monolog 1.x -> 2.0 compatibility problem.
Laravel 6.0 newly depend on Monolog 2.0 instead 1.x.
Illuminate/Log/LogManager.php use Monolog\Handler\HandlerInterface.
The interface has setFormatter() in Monolog 1.x (old).
However In Monolog 2.0, setFormatter() moved to Monolog\Handler\FormattableHandlerInterface.
LogManager must check FormattableHandlerInterface before call setFormatter() if there are Monolog 2.0.
My config/logging.php is following.
'fluent' => [
'driver' => 'monolog',
'level' => 'info',
'handler' => env('FLUENTD_ENABLE', true) ? App\Logging\FluentdHandler::class : Monolog\Handler\NullHandler::class,
],
Did you add these changes? https://github.com/laravel/laravel/commit/c70c986e58fe1a14f7c74626e6e97032d4084d5f
@driesvints
No. I use NullHandler as my custom monolog channel.
But I think that this null channel will occur the same problem.
I managed to reproduce this. Thanks for reporting. Appreciating a PR if you could whip one up.
Most helpful comment
I managed to reproduce this. Thanks for reporting. Appreciating a PR if you could whip one up.