Request logging

Only available if AcrossWebModule is present.

In a web context the LoggingModule will register a servlet filter that logs request information. Every request will get a unique id assigned and attributes like the handler name, request url and request mapping will be logged if they can be determined.


By default request logging for all requests is enabled through using a servlet filter. This can be altered by setting the logging.request.logger property.

Additionally there are some properties to finetune the request logging, or you can create your own RequestLoggerConfiguration instance. Advanced configuration can be used to specify:

  • to which servlets the filter should apply (defaults to all)

  • the path patterns that requests should match before they are logged

  • the log level threshold that allows you to configure different log levels to be used when requests exceed certain durations

Enabling request logging for all requests except static resources - through properties
Enabling request logging for all requests except static resources - manually
LoggingModule loggingModule = new LoggingModule();
RequestLoggerConfiguration requestLoggerConfiguration = RequestLoggerConfiguration.allRequests();
requestLoggerConfiguration.setExcludedPathPatterns( Arrays.asList( "/across/**" ) );
loggingModule.setProperty( LoggingModuleSettings.REQUEST_LOGGER_CONFIGURATION, requestLoggerConfiguration );
The RequestLogger.INTERCEPTOR option can be used to enable request logging without the use of the servlet filter. Though it still works, this option is no longer actively supported.

MDC attributes

The RequestLoggerFilter adds two attributes to the MDC:


A generated id that uniquely identifies the request. By adding the requestId to every log appender, log statements can be traced back to a specific request.


A configured value identifying the application instance. Only if the ApplicationInfoModule is active.


The unique requestId is added to every response as a Request-Reference header.

Logging output

A request log entry is a tab-separated log message sent to the SLF4J logger named com.foreach.across.modules.logging.request.RequestLogger. The tab-separated log message contains the following fields:

  • Remote address

  • HTTP method

  • URL

  • Servlet path

  • Best matching request mapping

  • Handler name

  • View name

  • HTTP status code

  • Duration (ms)

Depending on the application configuration or type of request, certain fields might not be available. In that case a field-dependent default value (either empty, 0 or null) will be output, but the position of the field will always exist so tab-based parsing does not fail.

Logback configuration

The following section provides a common Logback example for configuration of request logging, and the resulting output.

Example logback configuration for request logging
<?xml version="1.0" encoding="UTF-8"?>
	<appender name="pages" class="ch.qos.logback.core.ConsoleAppender">

	<logger name="com.foreach.across.modules.logging.request.RequestLogger" level="debug" additivity="false">
		<appender-ref ref="pages"/>
Example log statement
2015-11-02 12:58:15,212	[5f18be5e-5b64-4c3a-9843-740f16c32641]	http-apr-8080-exec-4	DEBUG	GET	http://localhost:8080/logging/debug/across/browser/info/0	/debug/across/browser/info/0	/debug/across/browser/info/{index}	AcrossInfoController.showContextInfo(List,int,Model)	th/debugweb/layouts/acrossBrowser	200	784
Table 1. Anatomy of the log statement


2015-11-02 12:58:15,212

Request id




Log level


Remote address

HTTP method


Request URL


Servlet path


Request mapping


Handler name


View name


HTTP status code