app/Logging/JsonFormatter.php
<?php namespace App\Logging; use Monolog\Formatter\LineFormatter; class JsonFormatter extends LineFormatter { public function format($record) { return json_encode($record); } }
app/Logging/JsonFormatterApply.php
<?php namespace App\Logging; use App\Logging\LineExFormatter; class JsonFormatterApply { public function __invoke($logging) { $exFormatter = new JsonFormatter(); foreach ($logging->getHandlers() as $handler) { $handler->setFormatter($exFormatter); } } }
config/logging.php
'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['bugsnag', 'daily'], 'tap' => [ App\Logging\JsonFormatterApply::class, ], ],