0
votes

When I don't specify a logfile in the virtual host sections of my conf-file the logs are written in the file specified in httpd.conf (=access_log). A log-entry would look like this:

SOMEIP - - [22/Jan/2013:18:34:08 +0100] "GET / HTTP/1.1" 200 1752 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/SOMEIP Safari/537.17"

SOMEIP - - [22/Jan/2013:18:34:08 +0100] "GET /img/homepage_bg.png HTTP/1.1" 304 - "http://DOMAIN/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) C$

But when I define a log file in the virtual host section the new log file contains different information:

SOMEIP - - [22/Jan/2013:18:33:34 +0100] "GET / HTTP/1.1" 200 1752

SOMEIP - - [22/Jan/2013:18:33:34 +0100] "GET /img/homepage_bg.png HTTP/1.1" 304 -

i define the log file like this:

CustomLog logs/DOMAIN-access_log common

Why does a custom log contain less information than the general log where all virtual hosts log in by default?

2
Check your master log format vs. the common log format you've specified there. Here's the Apache guide on how to configure log formats: httpd.apache.org/docs/2.2/mod/mod_log_config.htmlDavid Ravetti

2 Answers

0
votes

You need to define the alias "common" with a log format that includes the user-agent.

LogFormat "%h %l %u %t \"%r\" %>s %b "%{User-agent}i" common

0
votes

You didn't say what flavour of Linux you're using. Any decently configured Apache (for example the Debian-based ones like Ubuntu, Mint, etc.) will already have a fitting LogFormat containing the user-agent in their configuration. Look for all the lines matching LogFormat. You should find something like this:

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

Just use the combined or even the vhost_combined parameter for your logfile:

CustomLog logs/DOMAIN-access_log combined

You should also look at the documentation for the Custom Log Formats.