首先,我是逐个对每个虚拟主机进行配置的,找到一个虚拟主机,添加如下内容
1 2 3 |
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common CustomLog "/usr/logs/logs/access_log" combined |
然后,这样的话当前的虚拟主机的日志就会放到/usr/logs/logs/access_log
具体位置如下:
1 2 3 4 5 6 7 8 9 10 |
<VirtualHost *:80> ... LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common CustomLog "/backup/logs/access_log" combined </VirtualHost> |
如果要添加按照日期进行划分,如下请修改
(就是修改这一句:
1 |
CustomLog "/backup/logs/access_log" combined |
)
CustomLog “|/usr/local/apache/bin/rotatelogs /backup/logs/abc.%Y%m%d 86400″ common
/usr/local/apache/ apache路径
/backup/logs 日志路径
abc 日志前缀
%Y%m%d 后缀格式
86400 分割时长
具体日志命名如下:abc.201309135
如下部分为啥会有俩,暂时搞不明白,应该下边的可以去掉,请高人指点
1 2 |
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common |
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021