Original address: http://un173.blog.51cto.com/8263566/1598346
Manage Apache server For some years, though Nginx has been robbed of many thunder in recent years, I still love Apache.
Like its powerful concurrent processing power, and the free choice between forker and the worker mode of pleasure, haha.
Familiar with the Linux Apache operation of the friends, how many will encounter the Apache log file is too large problems, the site just online will not care about this problem, because the traffic is small, Natural Error.log and Access.log file content is also small, file capacity is small, therefore, the configuration will not consider what the Apache log maintenance strategy what.
When website traffic goes up to a certain level, a single error.log or access.log will not be able to cope with the growing log files and the need for log analysis.
The idea is to limit the size of the file, and then roll back, which is often said Apache log segmentation and round-robin.
How to solve this problem correctly, there are many articles on the net, here to tidy up a few, stay as a memo.
1, correctly solve the Apache log file too big problem
2. Solve the Apache log file too big problem (split Apache log by day)
3, Apache Error.log log file too big how to do?
4, Apache access.log log file too big how to do
5, Apache log file is too large how to use the log rolling resolution?
6, Apache log file is too large how to do log round?
I refer to the above information, completed the Apache log parts of the rollback operation, each log file is limited to the specified size, and then generate log files by day, observed a period of time, the effect is good.
The following is a description of the configuration of my Apache log rollback:
Default configuration:
12 |
CustomLog "logs/access.log" common ErrorLog "logs/error.log" |
The modified configuration:
123 |
CustomLog "|bin/rotatelogs /var/logs/logfile 86400" common CustomLog "|bin/rotatelogs /var/logs/logfile 5M" common ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M" |
Example 2:
12345678 |
# 限制错误日志文件为 1M ErrorLog “|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 1M” # 每天生成一个错误日志文件 #ErrorLog “|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 86400″ # 限制访问日志文件为 1M CustomLog “|bin/rotatelogs.exe -l logs/access-%Y-%m-%d.log 1M” common # 每天生成一个访问日志文件 #CustomLog “|bin/rotatelogs.exe -l logs/access-%Y-%m-%d.log 86400″ common |
If you also encounter the Apache log file growth too fast, log file too large problem, may wish to try.
The method is very simple and the effect is obvious.
How to solve the problem of Apache log file too big