rollbar / rollbar-php-laravel

Rollbar error monitoring integration for Laravel projects
https://docs.rollbar.com/docs/laravel
140 stars 39 forks source link

When in Dev Emergency Logging #154

Closed samuel-lujan closed 1 year ago

samuel-lujan commented 1 year ago

When in development not all of my teammates have the rollbar key in .env. Then when logging always log with an Emergency Log. laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. This could disturb when debugging and loggin errors to solve bugs.

We should have some validation if in env development, and rollbar_key is missing do not log on rollbar.

LeebranZadwell commented 1 year ago

This is for folks, like me, who stumbled across this note while seeing if there was a native rollbar solution.

The easiest way to approach this is to update your logging.php config file to not include rollbar as a logging driver when in your (testing, or local) environments that don't include the rollbar integration. Makes sense that this is a "problem" that lives outside of rollbar's scope.

/* within /app/config/logging.php */
$channels = ['daily']; // as an example.

if(! in_array(config('app.env'), ['environment_one', 'testing', 'etc...'])) {
  $channels = ['daily', 'rollbar'];
}

/* then below in your actual configuration, you want to pass the $channels value where you define your channels/drivers. */

For clarity to the intrepid reader, the benefits of doing this are not only having valid values in your configuration files, regardless of environment, but also your laravel.log starts to explode with "using emergency logger" messages, so cleaning that up is always nice.