首页 > 代码库 > apache 2.4.4 自动分割日志,按年月日生成

apache 2.4.4 自动分割日志,按年月日生成

<VirtualHost *:80>
#风来了.呆狐狸
DocumentRoot "/www/wwwroot/www.lanmps.com"
ServerName www.lanmps.com
DirectoryIndex  index.html index.php index.htm
ErrorLog "/www/wwwLogs/logs/www.lanmps.com/_error.error_log"
CustomLog "|/www/lanmps/apache/bin/rotatelogs /www/wwwLogs/logs/www.lanmps.com/%Y_%m_%d.access.log 86400" common
	<Directory /www/wwwroot/www.lanmps.com>
    Options -Indexes
    AllowOverride All
    Require all granted
	</Directory>
</VirtualHost>


如果限制日志文件大小800M,超过该大小自动切割文件,可以如下设置

CustomLog "|/www/lanmps/apache/bin/rotatelogs /www/wwwLogs/logs/www.lanmps.com/%Y_%m_%d.access.log 86400  800M" common

关于apache rotatelogs 函数详解请看http://88fly.blog.163.com/blog/static/122680390201293172154395/

apache 2.4.4 自动分割日志,按年月日生成