How to enable access logs in WildFly / JBoss

WildFly users

In order to monitor HTTP requests, WildFly offers two options:

  • You can enable the HTTP Request dump
  • You can enable Access logs

Let’s see how to configure both options.

Enabling HTTP Request Dump

WildFly uses Undertow as Web server, which has deprecated the element Valve used in former Tomcat Web Server. You can still monitor HTTP logging by adding a Filter to your configuration as in this example:

<host name="default-host" >
     <filter-ref name="http-dumper"/>
    <filter name="http-dumper" class-name="io.undertow.server.handlers.RequestDumpingHandler" module="io.undertow.core" />

You can add the Filter to your configuration using the following CLI command:

/subsystem=undertow/configuration=filter/custom-filter=http-dumper:add(class-name="io.undertow.server.handlers.RequestDumpingHandler",  module="io.undertow.core")

The RequestDumpingHandler filter will produce a verbose output, therefore it’s recommended not to use it in production to avoid performance issues.

Enabling Access logs

On the other hand, if you just want to keep track of the access-log of your server then you have to enable the access-log setting of your Host as follows:

/subsystem=undertow/server=default-server/host=default-host/setting=access-log:add(pattern="%h %l %u %t \"%r\" %s %b \"%{i,Referer}\" \"%{i,User-Agent}\" Cookie: \"%{i,COOKIE}\" Set-Cookie: \"%{o,SET-COOKIE}\" SessionID: %S Thread: \"%I\" TimeTaken: %T")

Also, you need to set the record-request-start-time attribute to true for the listener:


This reflects in the following configuration:

<host name="default-host" alias="localhost">
    <location name="/" handler="welcome-content"/>
    <access-log pattern="%h %l %u %t &quot;%r&quot; %s %b &quot;%{i,Referer}&quot; &quot;%{i,User-Agent}&quot; Cookie: &quot;%{i,COOKIE}&quot; Set-Cookie: &quot;%{o,SET-COOKIE}&quot; SessionID: %S Thread: &quot;%I&quot; TimeTaken: %T"/>
    <http-invoker security-realm="ApplicationRealm"/>

As you can see, now Undertow writes access logs in a file named access_log.log, in the configuration/log folder:

~/jboss/wildfly-15.0.0.Final/standalone/log: ls -al
-rw-rw-r--. 1 wildfly wildfly  62997 Jan 17 10:39 access_log.log
-rw-rw-r--. 1 wildfly wildfly      0 Dec 17 15:59 audit.log
-rw-rw-r--. 1 wildfly wildfly 589363 Jan 17 10:38 server.log

Using tabs in access logs

By default, the delimiter character in the Access logs is the space character. To switch to a different type of character, you have to use XML escape sequences. With regards to tabs, the escape sequence is &#x9;

Therefore, a sample configuration which includes tabs in it could be the following one:

<host name="default-host" alias="localhost">
    <location name="/" handler="welcome-content"/>
    <access-log pattern="%h&#x9;%l&#x9;%u&#x9;%t&#x9;&quot;%r&quot;&#x9;%s&#x9;%b&#x9;&quot;%{i,Referer}&quot;&#x9;&quot;%{i,User-Agent}&quot;&#x9;&quot;%{i,COOKIE}&quot;&#x9;&quot;%{o,SET-COOKIE}&quot;&#x9;%S &quot;%I&quot;&#x9;%T"/>
    <http-invoker security-realm="ApplicationRealm"/>

JBoss AS 7 / JBoss EAP 6 users

To enable HTTP logging, you need to go to the deploy/jbossweb-tomcat55.sar directory. There you will see the server.xml file, to which you’ll need to add the following valve definition:

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

A Valve element represents a component that will be inserted into the request processing pipeline for the associated Catalina container. The Access Log Valve creates log files in the same format as those created by standard web servers. These logs can later be analyzed by standard log analysis tools to track page hit counts, user session activity, and so on. The files produces by this Valve are rolled over nightly at midnight.

Once you’ve restarted the server, Tomcat will create an access log.