0

how to empty .log file in Magento 2 from Terminal ?

  • system.log

  • exceptional.log

  • debug.log

  • Usually logs are generated by themselves, you can simply run rm -rf var/log/* That will delete the logs files, and then you whenever you load any page which has exception logs, these will be created – Gagan Feb 18 at 10:37
  • 2
    > var/log/debug.log – Robert_Szczepaniec Feb 18 at 10:53
  • please add as answer :) @Robert_Szczepaniec – Yann Martel Feb 18 at 12:49
2

As the other answers have pointed out, since the logs are autogenerated removing them should be fine. Although this will override any permission etc you set on the files.

If you are purley looking to empty the file you can use the truncate command.

truncate -s0 /var/www/site.com/var/log/exception.log

As a side note, if you are wanting to periodically empty logs. Then i would recommend setting up and configuring LogRotate. This will allow you to compress the old logs and store them for a set amount of time before scrapping them.

See the following thread on using LogRotate Limiting the size of system.log and exception.log files

| improve this answer | |
1

To empty log files you have to run below command from the command line

> system.log
> exception.log
> debug.log

Remember you need to be in var directory before run the above command. Also you can always delete the files and magento will auto generate them.

| improve this answer | |
0

You can remove those files. Then it will generate again Automatically

ca var/log/ sudo rm -R system.log exceptional.log debug.log

| improve this answer | |
0

rm rf var/log/* what you need to do is just delete log files.

| improve this answer | |
0

You can remove the log files from terminal using below command, it will not create any issue as log files again generated in var/log;

rm -rf magento_root/var/log/*;

For removing log files everyday i suggest create a cron on server using below code:

0 0 * * 0-6 cd /magento_root/; rm -rf var/log/*

Above cron will run everyday at 12:00 AM. Let me know if this is not working.

| improve this answer | |
0
> var/log/debug.log
> var/log/system.log
> var/log/exception.log
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.