2012-01-06 6 views
7

を動作を停止しますTomcatの起動時にグローバルリソースとして必要なクラスが含まれているためです。それはslf4jにログを書き込むので、slf4jとlogback jarも必要です。 JoranConfiguratorを使用してmyStateLogback.xmlをロードします。私は私の「複数のSLF4Jバインディング」がログに警告を取り除く場合は、私はTomcatの6に次のディレクトリ構造を持っている

myApp webappはCommons-Loggingにログを書き込みますが、slf4jへのログをすべて移動する準備としてslf4jからlogbackに移動したいので、jcl-over-slf4jブリッジを使用しています。上記の設定で

、ログすべての作品が、私は、起動時に次の警告が出ます:

SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/D:/tomcat/lib/logback-classic-0.9.29.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: Found binding in [jar:file:/D:/tomcat/webapps/myApp/WEB-INF/lib/logback-classic-0.9.29.jar!/org/slf4j/impl/StaticLoggerBinder.class] 

私はWebアプリケーションのlibディレクトリの外にlogback-古典取る場合、私は次の例外を取得:

Exception in thread "Timer-30" java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature 
     at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:284) 
     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:252) 
     at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156) 
     at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132) 
     at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272) 

私はWebアプリケーションのlibディレクトリから2 logback jarファイルを削除し、SLF4J-api.jarの場合、私は警告や例外なく何を取得していないが、私のWebアプリケーションからのログがmyStateLogback.xmlファイルによってピックアップされています私が欲しくないロガーです。私は望んでいないステートメントを除外することができますが、webappとjarの設定ファイルを別にしたいと思います。これを達成する方法はありますか?

私はtomcat 6.0.23、logback 0.9.29、slf4j 1.6.3を使用しています。

おかげで、 サラ

答えて

3

一つの可能​​な解決策を提示しlogbackのdocumentaitonにlogging separationの章があります。

+0

非常に興味深いと私はこの状況で動作すると思います。しかし、単純にするために、私たちはmyState.jarのtomcat juliロギングを使用し、それぞれのwebappにlogback/slf4j jarsを置いて独自のロギングを制御することに決めました。 – ssloan

1

新しい-Dlogback.debug = trueオプションを使用すると、実装を探すslf4j-apiのメッセージが表示されます。 (ロギングは、Javaの世界ではペットのようなものです)。

 
09:12:05,472 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy] 
09:12:05,472 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [jar:file:/home/FOO/BAR.jar!/logback-test.xml] 
09:12:05,487 |-INFO in [email protected] - URL [jar:file:/home/FOO/BAR.jar!/logback-test.xml] is not of type file 
09:12:05,656 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 
09:12:05,662 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT] 
09:12:05,700 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property 
09:12:05,729 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.mongodb.morphia.mapping.Mapper] to ERROR 
09:12:05,729 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.BAZ] to DEBUG 
09:12:05,729 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO 
09:12:05,730 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT] 
09:12:05,730 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 
09:12:05,732 |-INFO in [email protected] - Registering current configuration as safe fallback point 
関連する問題