0

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?

1

2 Answers 2

0

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

in which file should i find thie LogFormats? I have a domain.conf file where i define the vhosts. Do i have to define the LogFormat in this file or in another file? i'm using cent-os.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.