1、查看apache主配置文件
/usr/local/apache2/conf/extra/httpd-vhosts.conf
2、找到此行 ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
修改成如下配置:
ErrorLog "logs/test.com-error_log"
CustomLog "logs/test.com-access_log" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" 此行各参数解析:
%h 来源ip
%l
%u 用户
%t 时间
%r 动作(具体查看apache官方文档)
3、配置参数将日志切割
同样找到此两行
ErrorLog "logs/test.com-error_log"
CustomLog "logs/test.com-access_log" combined
改成以下配置:
ErrorLog "|usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/test.com- error_%Y%m%d_log 86400"
CustomLog "|usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/test.com-access_%Y%m%d_log 86400" combined
时间: 2024-09-30 06:41:08