apache的rotatelogs使用手记

今天妄图使用apache的rotatelogs来回卷Apache日志,翻看手册,很简单。
PS:我手上有APACHE2.2的英文手册。不过现在网络太方便了 还是在网站上看的 Apache2.2中文手册

1. 修改httpd.conf 文件
       把原来的:
       CustomLog logs/access_log common 
       修改为:
  CustomLog “|/usr/local/httpd/bin/rotatelogs /var/logs/%Y%m%d%H_access_log 7200 480 5M″ common2
2. 测试下httpd.conf 文件的错误
       httpd -t
       显示:
      Syntax OK!
 
3. 重启后收工

附:Apache中rotatelogs的使用方法
English原文:
rotatelogs [-l] <logfile> {<rotation time in seconds>|<rotation size in megabytes>} [offset minutes from UTC]

Add this:

TransferLog "|D:\httpd\apache\bin\rotatelogs /some/where 86400"

or

TransferLog "|D:\httpd\apache\bin\rotatelogs /some/where 5M"

to httpd.conf. The generated name will be /some/where.nnnn where nnnn is the
system time at which the log nominally starts (N.B. if using a rotation time,
the time will always be a multiple of the rotation time, so you can synchronize
cron scripts with it). At the end of each rotation time or when the file size
is reached a new log is started.

中文翻译:
rotatelogs [-l] <logfile> {<rotation time in seconds>|<rotation size in megabytes>} [offset minutes from UTC]

选项
logfile
它加上基准名就是日志文件名。如果logfile中包含’%',则它会被视为用于的strftime(3)的格式字串;否则,它会被自动加上以秒为单位的.nnnnnnnnnn后缀。这两种格式都表示新的日志开始使用的时间。
rotationtime
日志文件回卷的以秒为单位的间隔时间
offset
相对于UTC的时差的分钟数。如果省略,则假定为0,并使用UTC时间。比如,相对于UTC的时差分钟数,中国是第八时区,相差480分钟。
filesizeM
指定回卷时以兆字节为单位的后缀字母M的文件大小,而不是指定回卷时间或时差。

参考网址:
http://manual.phpv.net/apache22/programs/rotatelogs.html

« 上一篇 | 下一篇 »
只显示10条记录相关文章
卸载IE7、IE8回到IE6的正确方法 (浏览: 34, 评论: 0)
firefox浏览shtml时直接显示源代码问题 (浏览: 372, 评论: 0)
自动封杀非法连接http的IP (浏览: 1191, 评论: 1)
Linux下添加硬盘,分区,格式化详解 (浏览: 549, 评论: 0)
/etc/fstab 文件说明 (浏览: 571, 评论: 0)
定时清理旧的log文件 (浏览: 1157, 评论: 1)
linux iptables 屏蔽IP段 (浏览: 866, 评论: 0)
linux下crontab时间的格式说明 (浏览: 855, 评论: 0)
用Linux系统防火墙功能抵御网络攻击 (浏览: 1336, 评论: 1)
使用mod_evasive对抗DDos攻击 (浏览: 1372, 评论: 1)
Trackbacks
点击获得Trackback地址,Encode: UTF-8 点击获得Trackback地址,Encode: GB2312 or GBK 点击获得Trackback地址,Encode: BIG5
发表评论

评论内容(*):