Let's take a look at how to configure logs regardless of the date size.
The code is as follows: |
Copy code |
LogFormat "% h % l % u % t" % r "%> s % B" % {Referer} I "" % {User-Agent} I "combined CustomLog "E:/1408.log" combined |
The generated access log is too large and later than 100 GB, so it cannot be viewed. This is certainly not the way to search for the log storage by size.
The code is as follows: |
Copy code |
# Restrict the error log file to 1 MB 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 & Prime; # Restrict access log files to 1 MB CustomLog "| bin/rotatelogs.exe-l logs/access-% Y-% m-% d. log 1M 1M" common # Generate an access log file every day # CustomLog "| bin/rotatelogs.exe-l logs/access-% Y-% m-% d. log 86400 & Prime; common |
This is simple. Just put it in. The error log is shown below.
This section describes windows users. linux uses cronolog to separate apache logs.
The cronolog tool can be run in linux or on a windows host. The installation method of linux is very simple. You can do it by using make install. The setting method is the same after installation, the following describes how to configure a windows host.
Copy the cronolog.exe tool to the apachebin directory.
■ 2. Modify the httpd. conf configuration file and find the mlog line.
■ 3. Modify it to the following format: CustomLog "|/usr/www.111cn.net/sbin/cronolog/usr/local/apache/logs/% Y _ % m _ % d. access. log" combined
Here, logs are generated every day.
Here,/home/apache/logs indicates the path where your log is stored;/usr/local/sbin/cronolog indicates the path where cronolog is located, which can be viewed using the which cronolog Command; % Y _ % m _ % d indicates that the log files are separated by year, month, and day, so that a log file is generated in one month. If you want to generate a log file every day, it seems to be % Y % m % d
Restart apache and you will find that apache logs are generated by date, and the original apache log files will no longer record new access data.