Skip to content

[4.0] Logger cannot be created with cached Laravel config #64

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

Closed
jarnovanleeuwen opened this issue Sep 14, 2018 · 3 comments
Closed

[4.0] Logger cannot be created with cached Laravel config #64

jarnovanleeuwen opened this issue Sep 14, 2018 · 3 comments
Assignees
Milestone

Comments

@jarnovanleeuwen
Copy link

When caching your Laravel configs using artisan config:cache the Rollbar logger breaks:

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 at vendor/laravel/framework/src/Illuminate/Container/Container.php:948)

The problem is in the stopping condition of the service provider: https://github.com/rollbar/rollbar-php-laravel/blob/master/src/RollbarServiceProvider.php#L93. getenv always returns NULL when a cached config exists (which is good). Therefore, the Rollbar token is received from the config using key logging.channels.rollbar.token. However, the access token is stored under a different config key: logging.channels.rollbar.access_token. The result is that stop() returns true and the Rollbar logger never gets registered in the service container.

A workaround is to also include the token key in the config array:

'rollbar' => [
    'driver' => 'monolog',
    'handler' => \Rollbar\Laravel\MonologHandler::class,
    'access_token' => env('ROLLBAR_TOKEN'),
    'token' => env('ROLLBAR_TOKEN'), // Temporarily due to Rollbar-Laravel bug.
    'level' => env('ROLLBAR_LEVEL')
]
@jarnovanleeuwen
Copy link
Author

Just noticed #58 fixes this. Leaving this issue as it might contain some extra information about the cause of the bug.

@jessewgibbs
Copy link

Thanks for the report. We're planning to spend some time working on Laravel in the next week or so and should be able to review that PR and follow up on this issue.

@ArturMoczulski
Copy link

Thanks for reporting @jarnovanleeuwen Yes this was fixed in v4.0.1

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

No branches or pull requests

4 participants