For troubleshooting the problem of your website or web application, logs are one of the important information.

In Linux, by default, the logs are stored in /var/log/your_apache_service (e.g. httpd, apache2, etc.). There are mainly two types of logs.

The web access information which stores the visitor IP, time, full link, return code by default

Errors or warnings details returned from when accessing the web such as visitor IP, time, error messages by default.

However, you may want more information (e.g. what browser did the visitors use to access the link). To change the output of the logs, you have to update the apache configuration.

For example of httpd in RHEL-based Linux

# less /etc/httpd/httpd.conf

Find the string “LogFormat”. You may find something like the followings.

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

By default, 2 types of log formats are defined, combined and common. And scroll down a little bit to find the configuration below.

CustomLog "/var/log/httpd/access_log" common

It means that the log format “common” is being used. You can change “common” to “combined” and restart the apache.

Then the logs will log the browsers used and the referrer (where did the visitor access to the link from, e.g. google, yahoo, internal links, etc.)

If you have several web sites or web applications in the server, you can configure different log formats in virtual hosts.

For more available log formats, you can click here.