The Apache log file is too large. Solution (access. log error. log)

Source: Internet
Author: User
Tags apache log file apache log

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.