0

I try to build a standalone version (executable jar) of a webapp. So I use jetty to load the war file. The war file already contains slf4j and logback as dependencies. In my standalone app I have a logback.xml to define the logger definitions.

<?xml version="1.0" encoding="UTF-8"?>
    <configuration>    

  <appender name="app" class="ch.qos.logback.core.FileAppender">
    <file>/tmp/app.log</file>
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <root level="${log.level}">
    <appender-ref ref="app"/>
  </root>

</configuration>

This works fine, but it does still output the logging information for jetty on the console instead of the logging file (all of the app logging goes into my log file). In the jetty documentation I found that I need to include the logging framework also in my embedding app. So I included slf4j and logback, but now I get the SLF4J: Class path contains multiple SLF4J bindings. error and it does not log into my files.

How can I fix this?

Versions:

  • jetty: 9.0.1.v20130408
  • logback: 1.0.7
  • slf4j: 1.7.2
Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
tobr
  • 127
  • 1
  • 8
  • Maybe this can help http://stackoverflow.com/questions/14024756/slf4j-class-path-contains-multiple-slf4j-bindings – Paulino III Apr 18 '13 at 13:46

1 Answers1

0

In embedded mode you are controlling everything.

If this is just a single webapp, remove the dupliate jar files, and consider setting the WebAppContext.setParentLoaderPriority(true) and just using everything from 1 ClassLoader.

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136