How to solve the problem of too many apache log files in CentOS

Source: Internet
Author: User
Tags apache log

How to solve the problem of too many apache log files in CentOS

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.

Reference: http://hi.baidu.com/chinaweilu/item/591f6f166decbeeb5e53b1cc

Related Article

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.