Child pages
  • Logging
Skip to end of metadata
Go to start of metadata

Logging support

XWork provides its own layer to support logging - it allows to use many different implementations.

Currently XWork provides support for the following libraries (in that order base on classpath discovery):


To use given type of library add it as a Maven dependency or drop into WEB-INF/lib folder. XWork LoggerFactory class will use given logging provider if available.

To add logging to your application simply declare a Logger as follow:

Implementing my own factory

You plug in your own logging solution, simple extend LoggerFactory class and provide a delegate which implements Logger interface, like below:

JdkLoggerFactory which adds support for JDK logging
JdkLogger is a wrapper around java.util.logging.Logger and implements Logger interface

Check the source code to see more details.

Defining which factory to use

Now you must tell XWork/Struts2 to use your implementation, just define system property like below:


you can use the same to explicit tell the framework which implementation to use and don't depend on class discovery, eg.:




will enable Slf4j or Log4j2 even if there is commons-logging on classpath available (commons-logging is the first LoggerFactory to look for).