How to solve the problem that the Apache log file is too large
How to solve the problem that the Apache log file is too large
Method 1,
In httpd. conf, find
Change CustomLog logs/access. log common
CustomLog "|/usr/sbin/cronolog/usr/local/apache2/logs/access _ % Y % m % d. log" common
Change ErrorLog logs/error. log common
ErrorLog "|/usr/sbin/cronolog/usr/local/apache2/logs/error _ % Y % m % d. log" common
The log storage directory is in/usr/local/apache2/logs.
Restart apache to generate a log file every day.
Method 2,
In the apache configuration file, find
ErrorLog logs/error_log
CustomLog logs/access_log common
Change it
ErrorLog "|/usr/local/apache2/bin/rotatelogs/usr/local/apache2/logs/error _ % Y % m % d. log 86400 480"
CustomLog "|/usr/local/apache2/bin/rotatelogs/usr/local/apache2/logs/access _ % Y % m % d. log 86400 480" common
If you do not know how to set the 480 parameter for the first time, the log record time is 8 hours different from the server time. It turns out that rotatelogs has an offset parameter, which indicates the time difference (in minutes) relative to UTC and China is the eighth time zone, the difference is 480 minutes. 86400 indicates a day.
Appendix rotatelogs description
Rotatelogs logfile [rotationtime [offset] | [filesizeM]
Option logfile
The reference name is the log file name. If logfile contains '%', it is considered as a string in strftime (3) format; otherwise, it is automatically added with the. nnnnnnnnnn Suffix in seconds. Both formats indicate the start time of the new log.
Rotationtime
Interval of Log File rollback in seconds
Offset
The number of minutes relative to the UTC time difference. If it is omitted, it is assumed that it is 0 and UTC time is used. For example, to specify the local time of the area with the UTC time difference of-5 hours, this parameter should be-300.
FilesizeM
Specify the size of the file with the suffix M in MB when you roll back, instead of specifying the rollback time or time difference.
------------------------------------- I am a split line -------------------------------------
How to enable Apache Rewrite in Ubuntu
Key points after upgrading Apache 14.04 to 2.2 in Ubuntu 2.4
Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04
Compile and install LAMP in CentOS 5.9 (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12)
Source code for Web server architecture in RedHat 5.4 build the LAMP environment and application PHPWind
Build a WEB Server Linux + Apache + MySQL + PHP in the LAMP source code Environment
This article permanently updates the link address: