3

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?

0

3 Answers 3

2
<Directory "/livehelp">
     CustomLog /my/custom/access.log combined
     ErrorLog /my/custom/apache2/error.log
</Directory>
4
  • Can I put this within a <virtualHost *:80></virtualHost> ?
    – Ben
    Jul 23, 2010 at 14:38
  • if you want to apply this on a virtual host, you should put it into that virtual host configuration.
    – Ehsan
    Jul 23, 2010 at 14:45
  • At least on my test here you can't put CustomLog and ErrorLog inside a <Directory>
    – coredump
    Jul 23, 2010 at 14:48
  • @coredump - that's the same thing that happened here, it threw an error.
    – Ben
    Jul 23, 2010 at 15:03
4

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>
1

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

[1] http://httpd.apache.org/docs/2.2/logs.html#piped

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .