Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method to limit the size of Apache log files

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What is the way to limit the size of Apache log files, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.

Access.log will reach tens of megabytes or even hundreds of megabytes after the WEB server is running for a period of time, and if there are errors in the operation of Apache, the error.log will also grow to tens of megabytes. We know that the system consumes a lot of memory to read and write a large text file, so it is necessary to limit the size of the log file. Usually we set the parameters of Apache in {$apache} / conf/httpd.conf, but we do not find a configuration instruction that can set the log file size. By referring to http://httpd.apache.org/docs/2.0/programs/rotatelogs.html, the treasure name dictionary http://www.bbqmw.net/qm_bbqmbd/ can use apache's own program rotatelogs.exe (located in the {$log} / bin/ directory) to limit the log file size.

Usage: rotatelogs [- l] [offset minutes from UTC] or

Add this:

TransferLog "| rotatelogs / some/where 86400"

Or

TransferLog "| rotatelogs / some/where 5m"

To httpd.conf. The generated name will be / some/where.nnnn where nnnn is the system time at which the log nominally starts (N.B. if using a rotation time, the time will always be a multiple of the rotation time, so you can synchronizecron scripts with it). At the end of each rotation time or when the file size is reached a new log is started.

Examples of settings under Windows are as follows:

# limit error log file to 1m

ErrorLog "| 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 to log files to 1m

CustomLog "| 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

It should be similar under linux/Unix.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report