Browse Source

ログ設定

develop
sosuke.iwabuchi 2 years ago
parent
commit
96601ea570
2 changed files with 37 additions and 2 deletions
  1. +9
    -0
      app/Providers/AppServiceProvider.php
  2. +28
    -2
      config/logging.php

+ 9
- 0
app/Providers/AppServiceProvider.php View File

@@ -2,6 +2,9 @@


namespace App\Providers; namespace App\Providers;


use Illuminate\Queue\Events\JobProcessing;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;


class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
@@ -24,5 +27,11 @@ class AppServiceProvider extends ServiceProvider
// IDEヘルパー登録 // IDEヘルパー登録
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class); $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
} }

//Queue関連
Queue::before(function (JobProcessing $event) {
// Logのドライバー設定
Log::setDefaultDriver('queue');
});
} }
} }

+ 28
- 2
config/logging.php View File

@@ -18,7 +18,7 @@ return [
| |
*/ */


'default' => env('LOG_CHANNEL', 'stack'),
'default' => env('LOG_CHANNEL', 'web'),


/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@@ -89,7 +89,7 @@ return [
'handler_with' => [ 'handler_with' => [
'host' => env('PAPERTRAIL_URL'), 'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'), 'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'),
], ],
'processors' => [PsrLogMessageProcessor::class], 'processors' => [PsrLogMessageProcessor::class],
], ],
@@ -126,6 +126,32 @@ return [
'emergency' => [ 'emergency' => [
'path' => storage_path('logs/laravel.log'), 'path' => storage_path('logs/laravel.log'),
], ],

'web' => [
'driver' => 'daily',
'path' => storage_path('logs/web.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
// 'replace_placeholders' => true,
'permission' => 0666,
],

'batch' => [
'driver' => 'daily',
'path' => storage_path('logs/batch.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
// 'replace_placeholders' => true,
'permission' => 0666,
],
'queue' => [
'driver' => 'daily',
'path' => storage_path('logs/queue.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
// 'replace_placeholders' => true,
'permission' => 0666,
],
], ],


]; ];

Loading…
Cancel
Save