I have the following lines pertaining to loggin in my apache vhost file

SetEnvIf Request_URI "^/server-status$" dontlog
SetEnvIf Request_URI "^/haproxy-status$" dontlog
SetEnvIf Request_Method "OPTIONS" dontlog
CustomLog /var/log/apache2/access_log combined env=!dontlog
#ErrorLog  /var/log/apache2/error_log

#Remote logging -- handle by syslog
ErrorLog "|logger -p local3.info -t httperror"
CustomLog "|logger -p local3.info -t http" combined env=!dontlog

LogLevel warn

I don't really want to mess anything up as to where I wont be gettingm y logs properly, but I don't want to see duplicate lines for every entry either. Currently, If I make one request, I see one line for apache, then one line which I assume is haproxy forwarding it to my app, similar to this:

aa.bbb.ccc.dd - - [05/Oct/2010:02:29:51 +0000] "GET /the_url HTTP/1.1" 200 4 "-" "-"
eee.fff.gg.hh - - [05/Oct/2010:02:29:51 +0000] "GET /the_url HTTP/1.1" 200 4 "-" "-"
aa.bbb.ccc.dd - - [05/Oct/2010:02:31:03 +0000] "GET /another_url HTTP/1.1" 200 4 "-" "-"
eee.fff.gg.hh - - [05/Oct/2010:02:31:03 +0000] "GET /another_url HTTP/1.1" 200 4 "-" "-"

What should I do to prevent this?


Remember that log directives within a VirtualHost section can conflict with log directives from the "Main" configuration sections. Duplicate log lines are often caused by a line like CustomLog /var/log/apache2/access_log in the main configuration section and a second CustomLog inside a VirtualHost section.

Grep for "access_log" in all of your configuration files to see if there is another section responsible for the duplicated log lines.

If you really want to have separate logs for your VirtualHost, then be sure to write to separate log files:

In the main HTTP configuration:

CustomLog /var/log/apache2/access_log

Inside the section:

CustomLog /var/log/apache2/www.thisvhost.org/access_log

To Keep It Simple and prevent confusion, I usually avoid any logging directives within the VirtualHost section. You can split out the logs based on their VirtualHost name later. Just be sure to use a format like "Common Log Format with Virtual Host" (%v or %V).

Another possibility. Is anything from syslog.conf writing to the file at /var/log/apache2/access_log ? This is doubtful, because syslog uses a different log format.

  • That was it. I had 2 lines. I just ensured the vhost line was commented out. – coneybeare Oct 6 '10 at 23:17

Those two lines are from apache, haproxy uses a different log format.

  • ok, still there are duplicates. The first ip is the servers ip, the second is the callers ip. – coneybeare Oct 5 '10 at 4:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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