2017-04-12 89 views
0

我使用播放框架(2.5.5),而我試圖用沒有運氣log4j2庫集成有Java應用程序。與遊戲框架log4j2整合失敗

我收到以下錯誤,當我運行它: SBT -Dlog4j.configurationFile =的conf/log4j2.xml

SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/Users/shishir/repos/jio-money/jiomoney-wallet-backend/target/universal/stage/lib/ch.qos.logback.logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: Found binding in [jar:file:/Users/shishir/repos/jio-money/jiomoney-wallet-backend/target/universal/stage/lib/org.apache.logging.log4j.log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] 

我按照安裝指南和更新我的build.sbt:

lazy val root = (project in file(".")). 
    settings(commonSettings: _*). 
    disablePlugins(PlayLogback) 
... 

libraryDependencies ++= Seq(

"org.apache.logging.log4j" % "log4j-slf4j-impl" % "2.4.1" exclude("ch.qos.logback", "logback-classic"), 
"org.apache.logging.log4j" % "log4j-api" % "2.4.1" exclude("ch.qos.logback", "logback-core"), 
"org.apache.logging.log4j" % "log4j-core" % "2.4.1" 

我log4j2.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<Configuration status="WARN"> 
    <Appenders> 
     <Console name="console" target="SYSTEM_OUT"> 
      <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"/> 
     </Console> 
     <File name="file" target="/tmp/app.log"> 
      <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"/> 
    </File> 
    </Appenders> 
    <Loggers> 
     <Root level="info" additivity="true"> 
      <AppenderRef ref="console"/ level="DEBUG"> 
     <AppenderRef ref="file"/ level="TRACE"> 
     </Root> 
    </Loggers> 
</Configuration> 

請讓我知道,如果我缺少事端克,或如何解決它

回答

0

有你的classpath中引入兩個SLF4J綁定,您必須排除logback-classic從你的classpath結合。

+0

我明白,爲什麼我添加排除根在依賴列表(「ch.qos.logback」,「的logback經典」),並禁用PlayLogBack。然而,我看到2 SLF4J綁定 – user2286963

+0

Log4j2相關的工件沒有對logback的編譯依賴關係,我猜想其他工件取決於這些。 – wangyuntao