Home > PHP Framework > Laravel > body text

How to delete logs in laravel

WBOY
Release: 2022-02-24 15:33:11
Original
2651 people have browsed it

In laravel, you can use the truncate command to delete the log. This command is used to clear the specified data. Use this command to clear the contents of the "laravel.log" file. The syntax is "truncate -s 0 storage/logs /laravel.log".

How to delete logs in laravel

#The operating environment of this article: Windows 10 system, Laravel version 6, Dell G3 computer.

How to delete logs in laravel

1. How to delete (clear) the laravel.log file in Laravel

Sometimes phpstorm cannot open this file because it is too big

The laravel.log file cannot be cleared manually. For example, opening the file and selecting delete will have no effect.

There is a simple command to clear the laravel.log file

Enter this command at the command line

truncate -s 0 storage/logs/laravel.log
Copy after login

2. Custom log

For example, I have a text message log that I need to write, but I don’t want to write it to laravel.log. What to do? It’s very simple. Just add a driver directly to config/logging.php

 'sms' => [
            'driver' => 'daily',//单个文件还是按天
            'path' => storage_path('logs/sms.log'),//存储文件
            'level' => 'info',//日志级别
            'days' => 14,//时间周期
        ],
Copy after login

Call:

Log::channel('sms')->info('短信内容')
Copy after login

[Related recommendations: laravel video tutorial]

The above is the detailed content of How to delete logs in laravel. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template