Skip to content

'handler' config conflict #85

@Hornet-Wing

Description

@Hornet-Wing

I've been looking at using rollbar-agent to do the actual sending to Rollbar. However, it is not possible to currently configure it in the logging config file as the handler key is used by natively by Laravel (5.8). So When I attempt to use the following config:

'rollbar' => [
	'driver' => 'monolog',
	'level' => 'debug',
	'handler' => 'agent',
	'agent_log_location' => storage_path('logs/rollbar'),
	'access_token' => env('ROLLBAR_TOKEN'),
],

I get the following error:

[2019-07-26 16:35:20] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): agent must be an instance of Monolog\\Handler\\HandlerInterface at laravel-project\\vendor\\laravel\\framework\\src\\Illuminate\\Log\\LogManager.php:328)

So I was able to validate my suspicions by reverting the handler back to using Rollbar\Laravel\MonologHandler::class and editing $config in RollbarServiceProvider.php to overwrite the handler key just before it gets passed into Rollbar::init. This made everything work and Rollbar started logging to the folder.

So, either the the key for the handler (used by Rollbar) needs to be changed or a better solution would be to nest the Rollbar specific settings to prevent conflict in the future. For example:

Altered key:

'rollbar' => [
	'driver' => 'monolog',
	'handler' => Rollbar\Laravel\MonologHandler::class,
	'level' => 'debug',
	'rollbar_handler' => 'agent',
	'agent_log_location' => storage_path('logs/rollbar'),
	'access_token' => env('ROLLBAR_TOKEN'),
],

Nested settings:

'rollbar' => [
	'driver' => 'monolog',
	'handler' => Rollbar\Laravel\MonologHandler::class,
	'level' => 'debug',
	'rollbar_config' => [
		'access_token' => env('ROLLBAR_TOKEN'),
		'handler' => 'agent',
		'agent_log_location' => storage_path('logs/rollbar'),
	]
],

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions