原文:http://publib.boulder.ibm.com/httpserv/manual60/programs/rotatelogs.html

rotatelogs is a simple program for use in conjunction with Apache's piped logfile feature. It supports rotation based on a time interval or maximum size of the log.

Synopsis

rotatelogs [ -l ] [ -W ] logfile rotationtime|filesizeM [ offset ]

Options

-l
Causes the use of local time rather than GMT as the base for the interval or for strftime(3) formatting with size-based rotation. Note that using -l in an environment which changes the GMT offset (such as for BST or DST) can lead to unpredictable results! -l is supported with IBM HTTP Server 2.0 with cumulative fix PQ90698 or later-l is ignored when rotating based on file size on levels of IBM HTTP Server without APAR PK56939.
-W
Activates additional processing that monitors the web server parent process and exits the rotatelogs process if the parent is no longer running. This option alleviates situations where the rotatelogs processes become orphaned during shutdown or restart processing and never exit. It may take up to 30 seconds or more before orphaned rotatelogs processes are exited. It is recommended that this option be used only if you are experiencing orphaned rotatelogs processes.

-W support is added for APAR PK66924. This option is ignored when the operating system is not a Windows operating system.

logfile

The path plus basename of the logfile. If logfile includes any '%' characters, it is treated as a format string for strftime(3). Otherwise, the suffix.nnnnnnnnnn is automatically added and is the time in seconds. Both formats compute the start time from the beginning of the current period. For example, if a rotation time of 86400 is specified, the hour, minute, and second fields created by strftime(3) format will all be zero, referring to the beginning of the current 24-hour period (midnight).

The directory path, excluding the basename of the logfile, must already exist.

If you use a piped logger for the ErrorLog defined in the base server configuration , and your piped logger is unable to write to the logfile it's configured for, no error reporting from the server or the piped logging program will be available.

rotationtime
The time between log file rotations in seconds. The rotation occurs at the beginning of this interval. For example, if the rotation time is 3600, the log file will be rotated at the beginning of every hour; if the rotation time is 86400, the log file will be rotated every night at midnight. (If no data is logged during an interval, no file will be created.)
filesizeM
The maximum file size in megabytes followed by the letter M to specify size rather than time.
offset
The number of minutes offset from UTC. If omitted, zero is assumed and UTC is used. For example, to use local time in the zone UTC -5 hours, specify a value of -300 for this argument. In most cases, -l should be used instead of specifying an offset.

Examples

CustomLog "|/path/to/IHS/bin/rotatelogs /var/logs/logfile 86400" common

This creates the files /var/logs/logfile.nnnn where nnnn is the system time at which the log nominally starts (this 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 (here after 24 hours) a new log is started.

CustomLog "|/path/to/IHS/bin/rotatelogs -l /var/logs/logfile.%Y.%m.%d 86400" common

This creates the files /var/logs/logfile.yyyy.mm.dd where yyyy is the year, mm is the month, and dd is the day of the month. Logging will switch to a new file every day at midnight, local time.

CustomLog "|/path/to/IHS/bin/rotatelogs /var/logs/logfile 5M" common

This configuration will rotate the logfile whenever it reaches a size of 5 megabytes.

ErrorLog "|/path/to/IHS/bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M"

This configuration will rotate the error logfile whenever it reaches a size of 5 megabytes, and the suffix to the logfile name will be created of the formerrorlog.YYYY-mm-dd-HH_MM_SS.

Portability

The following logfile format string substitutions should be supported by all strftime(3) implementations, see the strftime(3) man page for library-specific extensions.

%A full weekday name (localized)
%a 3-character weekday name (localized)
%B full month name (localized)
%b 3-character month name (localized)
%c date and time (localized)
%d 2-digit day of month
%H 2-digit hour (24 hour clock)
%I 2-digit hour (12 hour clock)
%j 3-digit day of year
%M 2-digit minute
%m 2-digit month
%p am/pm of 12 hour clock (localized)
%S 2-digit second
%U 2-digit week of year (Sunday first day of week)
%W 2-digit week of year (Monday first day of week)
%w 1-digit weekday (Sunday first day of week)
%X time (localized)
%x date (localized)
%Y 4-digit year
%y 2-digit year
%Z time zone name
%% literal `%'

(转)rotatelogs - Piped logging program to rotate Apache logs的更多相关文章

  1. suanec-rotatelogs

    简介 一个简单的日志滚动器 业界已有大量优秀的日志滚动工具来限制日志大小 本工具只是仿制了Apache httpd中的rotatelogs 不同的是,工作模式参考了yarn namenode日志的管理 ...

  2. linux服务之httpd

    http://mirrors.cnnic.cn/apache/httpd/docs/ 英文pdf文档下载 Apache HTTP Project’s goal It is the Apache HTT ...

  3. How To Configure Logging And Log Rotation In Apache On An Ubuntu VPS

    Introduction The Apache web server can be configured to give the server administrator important info ...

  4. MyEclipse8.5集成Tomcat7时的启动错误:Exception in thread “main” java.lang.NoClassDefFoundError org/apache/commons/logging/LogFactory

    今天,安装Tomcat7.0.21后,单独用D:\apache-tomcat-7.0.21\bin\startup.bat启动web服务正常.但在MyEclipse8.5中集成配置Tomcat7后,在 ...

  5. MyEclipse8.5集成Tomcat7时的启动错误:Exception in thread “main” java.lang.NoClassDefFoundError org/apache/commons/logging/LogFactory

    今天,安装Tomcat7.0.21后,单独用D:\apache-tomcat-7.0.21\bin\startup.bat启动web服务正常.但 在MyEclipse8.5中集成配置Tomcat7后, ...

  6. 【转】MyEclipse8.5集成Tomcat7时的启动错误:Exception in thread “main” java.lang.NoClassDefFoundError org/apache/commons/logging/LogFactory

    http://www.cnblogs.com/newsouls/p/4021198.html 今天,安装Tomcat7.0.21后,单独用D:\apache-tomcat-7.0.21\bin\sta ...

  7. rotatelogs分割apache日志文件

    rotatelogs 截断日志,进行配置.但是保存httpd.conf 之后,服务器报错: 日志文件: piped log program ' /usr/sbin/rotatelogs logs/py ...

  8. linux Apache rotatelogs 故障原因及解决方案未生效

    rotatelogs 截断日志.构造.但保存vhost.conf 之后.serverhttpd -k restart 还是无法成功重新启动. 日志文件: (2)No such file or dire ...

  9. com.sun.org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException

    在日志中, 查看导入的包是否是 import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;

随机推荐

  1. delphicbuilder10_2_1 安装破解注册

    安装程序 1.解压delphicbuilder10_2_1.iso,以管理员身份运行..\delphicbuilder10_2_1\Install\Setup.exe——选择安装语言——点击OK(推荐 ...

  2. 解决Python查询Mysql中文乱码问题

    前段时间,自己瞎动手用Django写了一个更新zip包和sql到远程服务器的工具.但Python从Mysql中读取出来的中文字符会乱码,如下图: 解决办法:Python连接Mysql时指定charse ...

  3. 什么是数据管理DMS

    数据管理(Data Management)支持MySQL.SQL Server.PostgreSQL.PPAS.Petadata等关系型数据库,DRDS等OLTP数据库,ADS.DLA等OLAP数据库 ...

  4. 【LOJ】#3095. 「SNOI2019」字符串

    LOJ#3095. 「SNOI2019」字符串 如果两个串\(i,j\)比较\(i < j\),如果离\(a_{i}\)最近的不同的数是\(a_{k}\),如果\(j < k\)那么\(i ...

  5. Codeforces Round #574 (Div. 2)补题

    A. Drinks Choosing 统计每种酒有多少人偏爱他们. ki 为每种酒的偏爱人数. 输出ans = (n + 1)/2 >  Σki / 2 ? (n + 1)/2 - Σki / ...

  6. JZOJ.1150【贪心算法】IQ

    欢迎转载,请附上原链接https://www.cnblogs.com/Code-Garden/p/11276741.html(也没人会看) 一道对我来说较难的贪心题 题目描述 根据世界某权威学会的一项 ...

  7. nginx-host

    下载nginx镜像 docker pull docker.io/nginx:latest 由于calico网络不支持http协议,所以即使你在iptables中配置了nat路由,将访问宿主机80端口的 ...

  8. 27-Perl 进程管理

    1.Perl 进程管理Perl 中你可以以不同的方法来创建进程.本教程将讨论一些进程的管理方法. 你可以使用特殊变量 $$ 或 $PROCESS_ID 来获取进程 ID. %ENV 哈希存放了父进程, ...

  9. git的常用指令(一)

    1. 查看git远程的所有分支 git branch -a 2.查看本地已有的分支 git branch 3.本地检出一个新的分支并推送到远程仓库 一).创建本地分支 git checkout -b ...

  10. 获取url传来的参数

    //根据传递过来的参数name获取对应的值 function getParameter(name) { var reg = new RegExp("(^|&)" + nam ...