apache日志分离组件cronolog
1.1 概述
apache默认的日志都会记录到一个文件内
如果访问量过多,时间过长,将导致日志堆积,文件变大,影响apache的性能
cronolog是一个用于日志切分的软件,使用管道把输入定位到其他路径保存
1.2 安装
wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
tar xcvf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
sudo ./configure -–prefix=%INSTALL_DIR%
sudo make install
1.3 使用
修改apache的日志记录
CustomLog “|%INSTALL_DIR%/cronolog %APACHE_HOME%/apache/logs/cronolog/%Y/%m/%d/%H_access_log” combined
ErrorLog “|%INSTALL_DIR%/cronolog %APACHE_HOME%/logs/cronolog/%Y/%m/%d/error_log”
然后需要reload下apache
sudo service apache restart
接下来可以在对应的logs/cronolog里面找到分离开的日志
1.4 Cronolog的参书规则
Specifier |
Description |
%% | a literal % character |
%n | a new-line character |
%t | a horizontal tab character |
Time fields | |
%H | hour (00..23) |
%I | hour (01..12) |
%p | the locale’s AM or PM indicator |
%M | minute (00..59) |
%S | second (00..61, which allows for leap seconds) |
%X | the locale’s time representation (e.g.: “15:12:47”) |
%Z | time zone (e.g. GMT), or nothing if the time zone cannot be determined |
Date fields | |
%a | the locale’s abbreviated weekday name (e.g.: Sun..Sat) |
%A | the locale’s full weekday name (e.g.: Sunday .. Saturday) |
%b | the locale’s abbreviated month name (e.g.: Jan .. Dec) |
%B | the locale’s full month name, (e.g.: January .. December) |
%c | the locale’s date and time (e.g.: "Sun Dec 15 14:12:47 GMT 1996") |
%d | day of month (01 .. 31) |
%j | day of year (001 .. 366) |
%m | month (01 .. 12) |
%U | week of the year with Sunday as first day of week (00..53, where week 1 is the week containing the first Sunday of the year) |
%W | week of the year with Monday as first day of week (00..53, where week 1 is the week containing the first Monday of the year) |
%w | day of week (0 .. 6, where 0 corresponds to Sunday) |
%x | locale’s date representation (e.g. today in Britain: “15/12/96”) |
%y | year without the century (00 .. 99) |
%Y | year with the century (1970 .. 2038) |