2.0 Apache日志切割

#vim /usr/local/apache2/conf/extra/http-vhosts.conf  //修改对应虚拟主机配置文件

加入文件:

<VirtualHost *:80>

      DocumentRoot "/data/www"

     ServerName www.test.com

     ServerAlias www.aaa.com

  ErrorLog "|/usr/local/apache2/bin/rotatelogs -l     /usr/local/apache2/logs/error_%Y%m%d.log 86400"

     CustomLog "|/usr/local/apache2/bin/rotatelogs -l    /usr/local/apache2/logs/custom_%Y%m%d.log 86400"   combined

//ErrorLog错误日志,CustomLog访问日志。管道符|把日志交给rotatelogs这个Apache自带切割工具处理,-l用来校准时区为UTC北京时间,86400秒为一天切割一次。Combined为日志格式,日志格式在/usr/local/apache2/conf/http.conf里面定义。

 <IfModule mod_rewrite.c>

  RewriteEngine on

  RewriteCond %{HTTP_HOST} ^www.aaa.com$

  RewriteRule ^/(.*)$ http://www.test.com/$1 [R=301,L]

 </IfModule>


你可能感兴趣的:(2.0 Apache日志切割)