If you develop Java EE web services, I’m sure you’ve found yourself in a situation when you’d like to see HTTP requests coming to your application for a moment in order to help you debug an issue. Sure, you could extend ContainerRequestFilter and write a nice logging filter based on JAX-RS, but you just need something temporarily to help you diagnose this one issue you’re investigating. Luckily, WildFly provides a tool exactly for this purpose.

Undertow is a lightweight open-source Java web server, and the default web server in WildFly. It comes with several handlers, one of which is RequestDumpingHandler for logging HTTP exchanges.

For runtime activation of RequestDumpingHandler, execute the following CLI script:

Alternatively, you can adjust your WildFly configuration (e.g. standalone.xml) as follows:

If the filter is set up correctly, curl localhost:8080 (assuming a local WildFly instance listening on localhost:8080) makes a message similar to the following snippet appear in the server log:

Note that RequestDumpingHandler is verbose and offers basically no customization options. As such, it’s suitable for one-off debugging activities rather than continuous usage. Definitely consider turning it off for your production deployment.

If you’re looking for something like the access log from Apache HTTP Server, something more concise, customizable, and suitable for production, Undertow has you covered. To set up a simple access log, execute the following CLI command:

Alternatively, you can adjust your WildFly configuration (e.g. standalone.xml) as follows:

Afterwards, a curl request to the server root leads to the following message in the log:

The use-server-log option ensures the output is written to the server log instead of a separate file. Omitting it would result in requests being logged to a file located at $JBOSS_HOME/standalone/log/access_log.log by default. The format of the log messages is configurable through the pattern parameter. Several other configuration options are supported as well:

The examples in this post were tested using WildFly 10.0.0.Final and Undertow 1.3.15.Final.