aluedeke
aluedeke

Reputation: 55

Jetty 8 centralize logging with slf4j

i am currently try to configure centralized logging for jetty 8 with slf4j. I found the following [tutorial][1] but it seems not to work with jetty 8. Does someone knows how to do this with jetty 8?

Solution:

jetty-webapp-logging.xml must have the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<!-- =============================================================== -->
<!-- Enable Centralized Logging in the Jetty Server                  -->
<!-- =============================================================== -->

<Configure id="Server" class="org.eclipse.jetty.server.Server">
  <Ref id="DeploymentManager">
    <Call name="addLifeCycleBinding">
      <Arg>
        <New class="org.mortbay.jetty.webapp.logging.CentralizedWebAppLoggingBinding">
        </New>
      </Arg>
    </Call>
  </Ref>
</Configure>

Upvotes: 1

Views: 3035

Answers (1)

Joakim Erdfelt
Joakim Erdfelt

Reputation: 49462

While the the tutorial, Centralized Logging with Logback, was created for Jetty 9, all of the features it is using is available as well on Jetty 8.1.10.

Some advice:

  1. Use the correct version of the jetty-webapp-logging jar for Jetty 8.1.10.
  2. Use the correct version of the DOCTYPE when working with the XML files.
  3. The command lines using start.jar are the same.
  4. The start.ini changes are the same.

Finally, various logging examples can be found at

https://github.com/jetty-project/jetty-and-logback-example

(tip: build the maven projects then look in the various ${module}/target/jetty-distro/ for the configured distribution that these maven builds produce)

Upvotes: 1

Related Questions