How can we solve the problem of too many apache log files,

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

How can we solve the problem of too many apache log files,
Address: http://un173.blog.51cto.com/8263566/1598346

I have been managing apache servers for some years. Although nginx has gained a lot of popularity in recent years, I still love apache.

Like its strong concurrent processing capabilities and the pleasure of freely choosing between forker and worker modes, haha.

If you are familiar with apache O & M in linux, you may encounter a problem where the apache log file is too large. The website will not be concerned about this problem when it is launched. Because of the low traffic, it will cause a natural error. log and access. log Files have less content and a small file capacity. Therefore, apache log Maintenance policies are not considered during configuration.

When the website traffic increases to a certain extent, a single error. log or access. log cannot meet the increasing log file and log analysis requirements.

The idea is to limit the file size and perform rollback, that is, apache Log segmentation and polling.

 

How can we solve this problem correctly? There are a lot of existing articles on the Internet. Here I will organize a few articles and leave them for memo.

  • 1. properly solve the problem of too many apache Log Files

  • 2. Solve the Problem of too many apache log files (apache logs are split by day)

  • 3. What should I do if the apache error. log file is too large?

  • 4. What should I do if the apache access. log file is too large?

  • 5. How can I solve the problem of rolling logs when the apache log file is too large?

  • 6. How does one perform log rotation when the apache log file is too large?

Based on the above information, the author has completed the rollback of apache Log parts. Each log file is limited to a specified size, and then it is generated as a log file by nature. After a while, the effect is good.

 

The following is the configuration of My apache Log rollback:

Default Configuration:

12 CustomLog "logs/access.log" commonErrorLog "logs/error.log"

 

Modified Configuration:

123 CustomLog "|bin/rotatelogs /var/logs/logfile 86400" commonCustomLog "|bin/rotatelogs /var/logs/logfile 5M" commonErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M"

 

Example 2:

12345678 # Restrict the error log file to 1 MBErrorLog “|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 1M”# Generate an error log file every day#ErrorLog “|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 86400″# Restrict access log files to 1 MBCustomLog “|bin/rotatelogs.exe -l logs/access-%Y-%m-%d.log 1M” common# Generate an access log file every day#CustomLog “|bin/rotatelogs.exe -l logs/access-%Y-%m-%d.log 86400″ common


If you have encountered the problem that apache log files are growing too fast and the log files are too large, try again.

The method is simple and the effect is obvious.

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.