Laravel : How to Log INFO to separate file

后端 未结 5 1116
轻奢々
轻奢々 2020-12-13 05:48

How to specify a separate file for logging INFO in Laravel 5.1?

Any immediate help will be highly appreciable. Thanks

5条回答
  •  难免孤独
    2020-12-13 06:29

    In Laravel 5.6 you can create your own channel in config\logging.php. If you have upgraded from an older Laravel version you need to create this file (https://laravel.com/docs/5.6/upgrade).

    Add this to you channel array in config\logging.php

    'your_channel_name' => [
                'driver' => 'single',
                'path' => storage_path('logs/your_file_name.log'),
            ],
    

    You can then call any of the 8 logging levels like that:

    Illuminate\Support\Facades\Log::channel('your_channel_name')->info('your_message');
    

    The logs will be stored in logs/your_file_name.log

提交回复
热议问题