Linux system Apache log file configuration detailed

Source: Internet
Author: User
Tags apache log file file size local time time interval apache log


Apache log file settings under Linux system (generate a separate log file per day)
Introduction:
Apache default installation, log record only one file, after a long time, this file will become very large, the administrator to view the analysis log, the light to open the log will take a long time, and even affect the server running.

Here to teach you to set up Apache, let the server generate a separate log file every day, so the management, analysis log will be more convenient.


Vi/etc/httpd/conf/httpd.conf #编辑文件
#ErrorLog Logs/error_log #注释此行, add the following line
ErrorLog "|rotatelogs/var/log/httpd/error_log%y%m%d.log 86400" #每天单独生成一个日志文件
#CustomLog Logs/access_log Common #注释此行, add the following line
Customlog "|rotatelogs/var/log/httpd/access_log%y%m%d.log 86400" common #每天单独生成一个日志文件
Note that the full path must be filled

2012-7-20 modified. If you use the LAMPP path without any configuration, you need to use an absolute path to call Rotatelogs

Customlog "/opt/lampp/bin/rotatelogs/var/log/httpd/access_log%y%m%d.log 86400 480″common

If you configure the host, you can modify the location of the extra/http-vhost.conf file accordingly

ErrorLog "|rotatelogs logs/yjw-%y_%m_%d-error_log.log 86400 480″
That's not going to work.

Extensions: If you want to disable Apache log files, you can set the following
Errorlog/dev/null #禁用错误日志
Customlog/dev/null Common #禁用访问日志



Rotatelogs is a simple program that is used in conjunction with the Apache Piping logging feature. Example:

Customlog "|bin/rotatelogs/var/logs/logfile 86400″common
This configuration establishes the file "/var/logs/logfile.nnnn", where the nnnn is the system time at which the nominal log is started (this time is always a multiple of the scrolling time and can be used for the synchronization of cron scripts). When the scrolling time arrives (in this case, 24 hours later), a new log is generated.

Customlog "|bin/rotatelogs/var/logs/logfile 5M" common
This configuration scrolls this log when the log file size grows to 5 megabytes.

ErrorLog "|bin/rotatelogs/var/logs/errorlog.%y-%m-%d-%h_%m_%s 5M"
This configuration scrolls the log when the error log size grows to 5 megabytes, and the log file name suffix is created in the following format: Errorlog. Yyyy-mm-dd-hh_mm_ss.

Rotatelogs syntax

Rotatelogs [-l] logfile [rotationtime [offset]] | [Filesizem]

-L
Use local time instead of GMT time as a time benchmark. Note: using-l in an environment that changes the GMT offset (such as daylight saving time) can lead to unpredictable results.
LogFile
It plus the reference name is the log file name. If logfile contains "%", it is treated as a format string for strftime (), otherwise it is automatically appended with the ". nnnnnnnnnn" suffix in seconds. Both of these formats indicate when the new log is to be used.
Rotationtime
The time interval in seconds that the log file scrolls.
Offset
The number of minutes of time difference relative to UTC. If omitted, it is assumed to be "0″ and use UTC time." For example, to specify local time for a region that has a UTC difference of "-5 hours", this argument should be " -300″." 480 China low Area deviation 8 hours
Filesizem

Specifies to scroll in filesizem file size, rather than by time or slack.

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.