Jboss server 4.0.2 – Enabling access logs

On Jboss AS 4.0.2 servers, the HTTP access logs, that shows requests, origin IP, time, and so on are disabled by default.

For enabling the log, we need to go to the server.xml file that is on deploy/jbossweb-tomcat55.sar. For example if we are using the default Jboss instance, we need to go to: /opt/jboss/server/default/deploy/jbossweb-tomcat55.sar

Editing the server.xml file that is on this directory we need to enable the section of the AccessLog Valve:

From this:

<!-- Access logger -->
 <!--
 <Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
 prefix="localhost_access_log." suffix=".log"
 pattern="common" directory="${jboss.server.home.dir}/log"
 resolveHosts="false" />
 -->

to this:

<!-- Access logger -->
 <Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
 prefix="localhost_access_log." suffix=".log"
 pattern="common" directory="${jboss.server.home.dir}/log"
 resolveHosts="false" />

By other words, by uncomment this XML section.
Restarting Jboss will make the access log file to appear on the log directory of the instance. For the example, this would be default/log directory.

The above configuration will create a common formatted log, but we can make the log the way we like, for example:

<Valve  className="org.apache.catalina.valves.AccessLogValve"
 prefix="access_log." suffix=".log"
 pattern="'%{X-Forwarded-For}i' %h %p %l %u %t %r %s %b '%{Referer}i'  '%{User-Agent}i'"
 directory="${jboss.server.home.dir}/log"
 resolveHosts="false" />

Note that we are using a different class for the log in this example.
For more information check out this: http://tomcat.apache.org/tomcat-4.1-doc/config/valve.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s