我们在我们的服务器上有一个实时的帮助,可以想象会产生大量的访问日志。 目前他们被追加到他们运行的站点的所有其他访问日志中。 这使得难以通过错误日志进行sorting。 有没有一种方法可以指定/ livehelp中的任何内容进入不同的日志文件?
<Directory "/livehelp"> CustomLog /my/custom/access.log combined ErrorLog /my/custom/apache2/error.log </Directory>
如果您将/ livehelp移动到其自己的VirtualHost (需要自己的HostName),则可以自定义日志以将它们分开。 您将使用CustomLog和ErrorLog指令来指定这些日志的位置。
<VirtualHost *:80> ServerName livehelp.example.com DocumentRoot /path/to/the/livehelp/folder ErrorLog logs/livehelp-error_log CustomLog logs/livehelp-access_log combined </VirtualHost>
您可以使用apache的pipe道日志[1]function。 创build一个shell脚本
#!/bin/sh PATTERN="/livehelp" FLAGS="-v" if [ "x$1" == "xlive" ]; then FLAGS="" fi; grep $FLAGS "$PATTERN" > $2
(未经testing,需要改进)
现在添加
CustomLog "|/path/to/script live /var/log/live" combined
和
CustomLog "|/path/to/script std /var/log/std" combined
到Apacheconfiguration
如果你需要,你可以在这里添加更多的过滤