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

"Unable to create configured logger. Using emergency logger....NullHandler" error #150

Open
shaifulborhan opened this issue Mar 12, 2023 · 7 comments
Assignees
Labels
Type: Question Request for information about a components operation.

Comments

@shaifulborhan
Copy link

shaifulborhan commented Mar 12, 2023

Laravel 8.x
PHP 8.1.x
rollbar/rollbar-laravel v7.2.0

laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): NullHandler must be an instance of Monolog\\Handler\\HandlerInterface at /project/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:372)

My laravel.log file has been flooded with this error after updating PHP from 7.4.x to 8.1.x and rollbar/rollbar-laravel from 7.0.0 to 7.2.0.

I followed the installation here https://docs.rollbar.com/docs/laravel#laravel-6-through-9 but nothing needs to be updated as far as I am concerned because my Laravel version doesn't change.

Please advise.

@danielmorell danielmorell self-assigned this Mar 13, 2023
@danielmorell danielmorell added the Type: Question Request for information about a components operation. label Mar 13, 2023
@danielmorell
Copy link
Collaborator

I am not sure why you are getting that error. NullHandler is a part of monolog/monolog itself and is an instance of the Monolog\Handler\HandlerInterface interface.

I can offer a couple possibilities but none of them seem like a clear option.

  1. Your cached config could be stale. Try running php artisan config:cache.
  2. You somehow have two versions of monolog/monolog available in your environment. Try running composer update monolog/monolog followed by composer dump.
  3. You have a NullHandler object in another package and accidentally, imported that instead of Monolog\Handler\NullHandler.

If none of those seem to resolve the issue and you still can't figure it out, please post the exact version installed for the following packages...

  1. rollbar/rollbar
  2. rollbar/rollbar-laravel
  3. monolog/monolog
  4. laravel/framework

@vbezruchkin
Copy link

vbezruchkin commented Mar 15, 2023

Hello,

I have the same issue. I just followed the correct instructions:

[2023-03-15 22:07:20] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Rollbar\\Laravel\\MonologHandler must be an instance of Monolog\\Handler\\HandlerInterface at /.../vendor/laravel/framework/src/Illuminate/Log/LogManager.php:384)

Latest versions of the libraries + Laravel 10.

This can help:

https://laravel.com/docs/10.x/upgrade#monolog-3

@danielmorell
Copy link
Collaborator

@vbezruchkin what version of rollbar/rollbar-laravel are you using?

@beltranbot
Copy link

Had this same issue occur to me using the following versions:

  • rollbar/rollbar v4.0.1
  • rollbar/rollbar-laravel v8.0.0
  • monolog/monolog 3.3.1
  • laravel/framework v10.11.0

After closely reviewing the issue I noticed that I accidentally had set up the environment variable as ROLLBAR_token instead of ROLLBAR_TOKEN . So just be aware that this misconfiguration can result in this very same error.

@jpylisela
Copy link

jpylisela commented Sep 29, 2023

Same issue here, please advise.

PHP v8.1.23

rollbar/rollbar 4.0.1
rollbar/rollbar-laravel 8.0.0
monolog/monolog 3.4.0
laravel/framework 10.24.0

My ROLLBAR_TOKEN is set correctly in the .env

The error is slightly different:

[2023-09-29 13:56:32] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Unresolvable dependency resolving [Parameter #0 [ <required> array $config ]] in class Rollbar\\RollbarLogger

I looked into the Monolog upgrade instructions, but I can't immediately see anything that's relevant for the setup:

https://laravel.com/docs/10.x/upgrade#monolog-3

Current implementation:

    'channels' => [
        'stack' => [
            'driver'            => 'stack',
            'channels'          => ['rollbar', 'single'],
            'ignore_exceptions' => false,
        ],

        'single' => [
            'driver' => 'single',
            'path'   => storage_path('logs/laravel.log'),
            'level'  => env('LOG_LEVEL', 'debug'),
        ],

        'rollbar' => [
            'driver'       => 'monolog',
            'handler'      => \Rollbar\Laravel\MonologHandler::class,
            'access_token' => env('ROLLBAR_TOKEN'),
            'environment'  => env('APP_NAME', 'production'),
            'level'        => 'warning',
        ],

@danielmorell
Copy link
Collaborator

It is possible this could be related to an autoloading issue. Try running...

composer dump

@jpylisela
Copy link

It is possible this could be related to an autoloading issue. Try running...

composer dump

Did not fix it for me unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Request for information about a components operation.
Projects
None yet
Development

No branches or pull requests

5 participants