Skip to content
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

[6.0] Monolog Channel can't use NullHandler in Monolog 2.0 #30026

Closed
ktanakaj opened this issue Sep 18, 2019 · 3 comments · Fixed by #30123
Closed

[6.0] Monolog Channel can't use NullHandler in Monolog 2.0 #30026

ktanakaj opened this issue Sep 18, 2019 · 3 comments · Fixed by #30123
Labels

Comments

@ktanakaj
Copy link

  • Laravel Version: 6.0.3
  • PHP Version: 7.3

Description:

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.

Steps To Reproduce:

My config/logging.php is following.

'fluent' => [
    'driver'  => 'monolog',
    'level' => 'info',
    'handler' => env('FLUENTD_ENABLE', true) ? App\Logging\FluentdHandler::class : Monolog\Handler\NullHandler::class,
],
@driesvints
Copy link
Member

Did you add these changes? laravel/laravel@c70c986

@ktanakaj
Copy link
Author

@driesvints
No. I use NullHandler as my custom monolog channel.
But I think that this null channel will occur the same problem.

@driesvints
Copy link
Member

I managed to reproduce this. Thanks for reporting. Appreciating a PR if you could whip one up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants