We have a live help on our server that generates an insane amount of access logs as you can imagine. Currently they're appended to all of the other access logs for the site they run on. This makes it difficult to sort through the error logs. Is there a way I can specify that anything within /livehelp go into a different log file?
3 Answers
<Directory "/livehelp">
CustomLog /my/custom/access.log combined
ErrorLog /my/custom/apache2/error.log
</Directory>
-
-
if you want to apply this on a virtual host, you should put it into that virtual host configuration.– EhsanJul 23, 2010 at 14:45
-
At least on my test here you can't put
CustomLog
andErrorLog
inside a<Directory>
– coredumpJul 23, 2010 at 14:48 -
@coredump - that's the same thing that happened here, it threw an error.– BenJul 23, 2010 at 15:03
If you move /livehelp to its own VirtualHost (which requires its own HostName) you can customize the logs to keep them separate. You would use the CustomLog and ErrorLog directives to specify the location for those logs.
<VirtualHost *:80>
ServerName livehelp.example.com
DocumentRoot /path/to/the/livehelp/folder
ErrorLog logs/livehelp-error_log
CustomLog logs/livehelp-access_log combined
</VirtualHost>
You could use the piped log [1] feature of apache. Create a shell script like
#!/bin/sh
PATTERN="/livehelp"
FLAGS="-v"
if [ "x$1" == "xlive" ]; then
FLAGS=""
fi;
grep $FLAGS "$PATTERN" > $2
(untested and needs improvement)
now add
CustomLog "|/path/to/script live /var/log/live" combined
and
CustomLog "|/path/to/script std /var/log/std" combined
to the apache config
you can add some more filtering here if you need