diff --git a/app/Providers/DiscourseServiceProvider.php b/app/Providers/DiscourseServiceProvider.php index 0e0d5321d..4fbe8c28a 100644 --- a/app/Providers/DiscourseServiceProvider.php +++ b/app/Providers/DiscourseServiceProvider.php @@ -7,6 +7,7 @@ use GuzzleHttp\HandlerStack; use GuzzleRetry\GuzzleRetryMiddleware; use Illuminate\Support\ServiceProvider; +use Illuminate\Support\Facades\Log; class DiscourseServiceProvider extends ServiceProvider { @@ -70,19 +71,8 @@ public function register() private function createGuzzleLoggingMiddleware(string $messageFormat) { return \GuzzleHttp\Middleware::log( - $this->getLogger(), + Log::channel('discourse'), new \GuzzleHttp\MessageFormatter($messageFormat) ); } - - private function getLogger() - { - if (! $this->logger) { - $this->logger = with(new \Monolog\Logger('discourse-api'))->pushHandler( - new \Monolog\Handler\RotatingFileHandler(storage_path('logs/discourse-api.log')) - ); - } - - return $this->logger; - } } diff --git a/config/logging.php b/config/logging.php index 5aa1dbb78..51f308d94 100644 --- a/config/logging.php +++ b/config/logging.php @@ -70,6 +70,13 @@ 'days' => 14, ], + 'discourse' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/discourse-api.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'days' => 14, + ], + 'slack' => [ 'driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'),