laravel 5.2 custom log file for different tasks

后端 未结 10 1125
再見小時候
再見小時候 2021-01-30 00:36

Can we create a custom log file for different purposes in laravel 5.2 like for order related log entries that should be in order.log and for payment related stuff the entry shou

10条回答
  •  我在风中等你
    2021-01-30 01:03

    This is supported in a much easier way now

    1. Create a channel

      goto: root/config/logging.php, under channels array add your custom channel i.e

          'payments' => [
              'driver' => 'single',
              'path' => storage_path('logs/payments.log'),
              'level' => 'info',
        ],
    
    1. In your route or controller write to this log
        Log::channel('payments')->info('A transaction has been made!');
    
    1. The payment logs can be found at /storage/logs/payments.log

    NOTE: extendible to enhance furthur your requirements

    Laravel version 5.6 Docs

提交回复
热议问题