Limit Apache log access.log file size

Source: Internet
Author: User
Tags local time apache log

You can configure Apache's own program Rotatelogs functionality in Apache's httpd.conf configuration file .

Rotatelogs is a simple program that works with the Apache pipeline log feature,

Reference: http://httpd.apache.org/docs/current/mod/mod_log_config.html

1 Create a new log every day

Customlog "|/usr/sbin/rotatelogs/etc/httpd/logs/access_log_%y-%m-%d 86400 480" combined

2nd log more than a certain size to generate new logs

Customlog "|/usr/sbin/rotatelogs/etc/httpd/logs/access_log_%y-%m-%d 5M" combined

3 rotatelogs Syntax

Rotatelogs[ -L]logfile  [  Rotationtime  [ offset  ] | [  FileSize m]

logfile
it adds the base name to the log file name. If logfile "%" is included, it is treated as strftime() the format string used, otherwise it is automatically appended with the " .nnnnnnnnnn " suffix in seconds. Both formats represent the time when the new log began to be used.
rotationtime
The
interval of time in seconds that the log file is scrolled.
offset
the number of minutes of the time difference relative to UTC. If omitted, it is assumed to be "0" and UTC time is used. For example, to specify local time for a region with a UTC difference of "-5 hours", this parameter should be " -300 ".
filesizeM
specifies scrolling as a filesizeM file size instead of scrolling by time or slack.
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 logs/error-%y-%m-%d.log 86400"
# Limit access log file to 1M
Customlog "|bin/rotatelogs.exe-l logs/access-%y-%m-%d.log 1M" common
# Generate one access log file per day
#CustomLog "|bin/rotatelogs.exe logs/access-%y-%m-%d.log 86400" common

Limit Apache log access.log file size

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.