Have you found that the log files generated by Apache are day-to-day, not very big? If you installed apache on drive C, it would be terrible. In a few days, the hard disk will be full, which is terrible, is there a way to optimize the log to make it less big? The answer is yes.
1. Stop the Apache service and delete the error. log and access. log files in the/logs/directory of Apache.
2. Open the conf/httpd. conf configuration file of Apache and find the following configuration information:
The code is as follows: |
Copy code |
ErrorLog logs/error. log CustomLog logs/access. log common |
Add the "#" sign before the preceding two lines of configuration code, and modify the code as follows:
The error log file error. log limits the error log file to 1 MB:
The code is as follows: |
Copy code |
ErrorLog "| bin/rotatelogs.exe-l logs/error-% Y-% m-% d. log 1M" |
Or generate an error log file every day:
The code is as follows: |
Copy code |
ErrorLog "| bin/rotatelogs.exe-l logs/error-% Y-% m-% d. log 86400" |
The log file access. log limits the access log file to 1 MB:
The code is as follows: |
Copy code |
CustomLog "| bin/rotatelogs.exe-l logs/access-% Y-% m-% d. log 1M mlog" common |
Or generate an access log file every day:
The code is as follows: |
Copy code |
CustomLog "| bin/rotatelogs.exe-l log/access-% Y-% m-% d. log 86400" common |
After the modification is complete, save the httpd. conf file and restart Apache. Will you check the log file again in two days? Certainly better.
The following describes how to clean the access. log and error. log files. I suspect there are other crawlers. I will be crawling several of my websites tomorrow.
The methods to optimize access. log and error. log are as follows:
The code is as follows: |
Copy code |
CustomLog "| D:/thridparty-system/java/apache2/bin/rotatelogs.exe D: /thridparty-system/java/apache2/logs/access _ % Y _ % m _ % d. log 86400 480 & Prime; common ErrorLog "| D:/thridparty-system/java/apache2/bin/rotatelogs.exe D: /thridparty-system/java/apache2/logs/error _ % Y _ % m _ % d. log 86400 480 & Prime; |
Everything is so simple, so that these two log files will start a new file every day, so that a single file will not be too large and cannot be opened, and the log information cannot be seen.