您的位置:首页 > 博客中心 > 电脑问题 >

window apache 日志分割

时间:2022-03-18 07:54

 apache  [ httpd.conf ]配置文件

  #ErrorLog "logs/error.log"

  ErrorLog "|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 2M"

Windows下虚拟主机的日志切割

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "D:/wamp/www"
    ServerName localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
</VirtualHost>

更改后

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "D:/wamp/www"
    ServerName localhost
    ErrorLog "|bin/rotatelogs.exe -l logs/localhost-error-%Y-%m.log 86400"  # 86400 可改为 2M 
    CustomLog "|bin/rotatelogs.exe -l logs/localhost-access-%Y-%m.log" common
</VirtualHost>

 或者使用下面这种

在apache的配置文件中找到
ErrorLog logs/error_log
CustomLog logs/access_log common

Linux系统配置方法:

将其改为 
ErrorLog "| /usr/local/apache/bin/rotatelogs /home/logs/www/%Y_%m_%d_error_log 86400 480"
CustomLog "| /usr/local/apache/bin/rotatelogs /home/logs/www/%Y_%m_%d_access_log 86400 480" common

Windows系统下配置方法:

#ErrorLog "|bin/rotatelogs.exe logs/vicp_net_error-%y%m%d.log 86400 480"
#CustomLog "|bin/rotatelogs.exe logs/vicp_net_access-%y%m%d.log 86400 480" common

第一次不知道设置480这个参数,导致日志记录时间和服务器时间相差8小时,原来是rotatelogs有一个offset参数,表示相对于UTC的时差分钟数,中国是第八时区,相差480分钟。86400是表示1天。

 

热门排行

今日推荐

热门手游