Redirecting embedded jetty log to log4j2

When using embedded jetty within an application, per default there is no support for log4j2. Using slf4j it is possible to redirect the logging to log4j2. But without this redirection there is no way to directly use it. But of course there is a way to use it. Only a piece of simple adapter code is required.

Writing an adapter for the jetty logging api

Jetty uses an own logging api that redirects logging events to a provided logging api. For that api a simple logging adapter is required. This adapter must extend the org.eclipse.jetty.util.log.AbstractLogger. Before starting jetty simply org.eclipse.jetty.util.log.Log.setLog(AbstractLogger) must be invoked in order to replace the default logging mechanism of jetty.
In order to get the example simply checkout the source code or go to github.


2 thoughts on “Redirecting embedded jetty log to log4j2

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.