Tuesday Oct 06, 2009

AWStats and Glassfish

AWStats is a free powerful tool that generates graphically web server statistics. This log analyzer works also in combination with the Glassfish Application Server.

To get the web statistic out form the glassfish server there are a few things to be payed attention for after you have installed AWStats successfully on your server. 

First off all you need to activate the Access Log in Glassfish. The Access Log is switched off per default.

 

Also it maks sense to use a new feature from glassfish which allows to generate a kind of standard log file format called Apache combined log format. This Log format gets out much more informations from a web server statistic. See Jan Luehe's Blog for details.

You can activate the Access Log in Glassfish using the Glassfish Console.

 

To activate the combined log format enter 'combined' in the Format Field.

Next it is also necessary to tell AWStats how to access the daily logfiles generated by glassfish server and which log file format (Apache combined log format) should be used by AWStats. Therefor it is necessary to edit the awstats.config file of your webdomain (on linux the config files are located in /etc/awstats/).

Edit the config File and change two important properties to optimize AWSats to work with glassfish:

LogFile

This property defines the location of the AccessLog files. These files are typical stored in the logs/access folder form the glassfish domain. Set these property like this:

LogFile="/usr/glassfish/domains/domain1/logs/access/server_access_log.%YYYY-0-%MM-0-%DD-0.txt"

where /usr/glassfish/ should point to your glassfish install directory. 

LogFormat

The second property is the LogFormat. This property has a default setting of "4" which indicates to use the Apache common log format. Change this Property to "1" to indicate to use the Apache combined log format.

After this changes the Web statistic of your glassfish server should look cool and gives you all the informations you are looking for.