Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 2 down vote accepted
<Directory "/livehelp">
     CustomLog /my/custom/access.log combined
     ErrorLog /my/custom/apache2/error.log
</Directory>
share|improve this answer
    
Can I put this within a <virtualHost *:80></virtualHost> ? –  Webnet Jul 23 '10 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 '10 at 14:45
    
At least on my test here you can't put CustomLog and ErrorLog inside a <Directory> –  coredump Jul 23 '10 at 14:48
    
@coredump - that's the same thing that happened here, it threw an error. –  Webnet Jul 23 '10 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>
share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.