diff --git a/src/Graylog2ServiceProvider.php b/src/Graylog2ServiceProvider.php index d70296f..3a23cf4 100644 --- a/src/Graylog2ServiceProvider.php +++ b/src/Graylog2ServiceProvider.php @@ -2,7 +2,6 @@ namespace Swis\Graylog2; -use Illuminate\Support\Facades\Log; use Illuminate\Support\ServiceProvider; class Graylog2ServiceProvider extends ServiceProvider @@ -18,7 +17,7 @@ public function boot() ]); // Register handler - $monoLog = Log::getMonolog(); + $monoLog = $this->getMonolog(); $monoLog->pushHandler(new Graylog2Handler(config('graylog2.log_level', 'debug'))); } @@ -29,4 +28,14 @@ public function register() { $this->app->singleton('graylog2', Graylog2::class); } + + /** + * @return \Monolog\Logger + */ + private function getMonolog() + { + return $this->app['log'] instanceof \Illuminate\Log\LogManager + ? $this->app['log']->driver() + : $this->app['log']->getMonolog(); + } }