Get the App
SLTechnology News&Howtos  ›  Development  › 

How to delete logs by laravel

Shulou Source: shulou.com Published: 2022-06-01 12:31:14 10月09日 Update

This article mainly introduces the relevant knowledge of "how laravel deletes the log". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "how to delete the log in laravel" can help you solve the problem.

In laravel, you can use the truncate command to delete the log, which is used to empty the specified data and use this command to empty the contents of the "laravel.log" file with the syntax of "truncate-s 0 storage/logs/laravel.log".

This article operating environment: Windows10 system, Laravel6 version, Dell G3 computer.

How does laravel delete the log?

1. How to delete (empty) laravel.log files in Laravel

Sometimes phpstorm can't open this file because it's too big.

Laravel.log files can not be emptied manually, such as opening files, selecting all delete will not have any effect.

There is a simple command to empty the laravel.log file using the

Enter this command at the command line

Truncate-s 0 storage/logs/laravel.log

II. Custom log

For example, I have an SMS log that I need to write, but I don't want to write to laravel.log. What should I do? it's very simple to add a driver to config/logging.php directly.

'sms' = > [' driver' = > 'daily',// single file or by day' path' = > storage_path ('logs/sms.log'), / / store file' level' = > 'info',// log level' days' = > 14 gamble / time period]

Call:

Log::channel ('sms')-> info (' SMS content') this is the end of the introduction on "how to delete logs in laravel". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Logs files commands content knowledge text messages industries different practical single periodic practical practical that is what to do manual effects data articles methods Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MariaDB Shulou Tech Info MySQL Apple