Enable logging for Spring own components under Jetty

I just wanted to share how to enable logging for Spring own components when running a Web application under Jetty (using jetty-maven-plugin). I spent a lot of time trying to figure this out so if you are lost like I was, keep reading.

By default, Spring uses Jakarta Commons Logging (JCL) framework, whereas Jetty uses SLF4J. The trick is to configure Spring to use JCL-to-SLF4 bridge which will delegate all JCL logging to SLF4J. This can be accomplished by declaring the following dependencies in the POM:


where ${slf4j.version} is a property that that defines the SLF4J version, i.e:


It is very important that these SLF4J dependencies are not declared as Jetty plugin dependencies. They must be declared for the entire POM, otherwise this is not going to work.

Next, here is my Jetty plugin declaration:

			<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">

The above setup was tested with Spring 3.2.3.RELEASE, SLF4J 1.7.5 and jetty-maven-plugin 9.0.4.v20130625.

This entry was posted in Spring. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

× nine = 72

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>