apache 访问日志
vim /usr/local/apache/conf/extra/httpd-vhosts.conf
修改两行
ErrorLog "logs/ping.com-error_log"
CustomLog "logs/ping.com-access_log" combined :日志格式
combined格式:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
%h 请求主机
%l
%u :用户, - 为没有
%t :时间
%r :动作
Referer :目标
User-Agent :浏览器标识
2.做切割处理
vim /usr/local/apache/conf/httpd.conf
CustomLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/apache/logs/ping.com-access_%Y%m%d_log 86400" combined
| 管道符,将访问日志输出给切割工具
/usr/local/apache/bin/rotatelogs -l :切割工具
/usr/local/apache/logs/ping.com-access_%Y%m%d_log :日志绝对路径(年月日格式) 86400 :单位为秒(按天分)
Errorlog :错误日志
重读配置文件
# 检查配置文件
/usr/local/apache2/bin/apachectl –t
# 重新加载配置文件
/usr/local/apache2/bin/apachectl graceful
最后更新于
这有帮助吗?