逐个对每个虚拟主机进行配置的,找到一个虚拟主机,添加如下内容

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

然后,这样的话当前的虚拟主机的日志就会放到/data/wwwlogs/apache/

<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 "/data/wwwlogs/apache/access_log" combined
</VirtualHost>

如果要添加按照日期进行划分,如下请修改:

CustomLog "/backup/logs/access_log" combined
CustomLog "|/usr/local/apache/bin/rotatelogs /data/wwwlogs/apache/access.%Y%m%d 86400" common

 

/usr/local/apache/                    apache路径

/data/wwwlogs/apache/           日志路径

access                                       日志前缀

%Y%m%d                                    后缀格式

86400                                       分割时长

具体日志命名如下:access.20140608