Home / VPS & Dedicated / Logging user agent data in Apache

Logging user agent data in Apache

Apache log
Question: How do I tell Apache to log user agent information?

Answer: Normally, Apache logs information about site visitors to /var/logs/httpd/ and uses files like access_log, error_log, etc. While it does give some information about the users, it does not include user agent information by default. User agent information looks like this:

"Mozilla/5.0 (compatible; MSIE 7.05; Windows XP)"

This can provide you with useful information about your website’s visitors. Fortunately, Apache has the capability to log user agents and a load of other information built into it. You just have to enable it. Furthermore, you can tell Apache to put user agent information in a separate file.

Edit the Apache configuration file, often called httpd.conf on Redhat/CentOS/Fedora servers, and add this line:

CustomLog logs/user_agents "%{user-agent}i"

That is all you have to do. Now user agent information will be logged to your /var/logs/user_agents file.

Source: Apache Week
Photo: Flickr

Check Also

servers

Importance of web hosting to business

The world of business is very ruthless and unfair in some cases. It is a …