我无法使用slf4j进行日志记录的配置工作.. 错误日志看起来像这样
INFO: visiting unvisited references
SEVERE: log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
SEVERE: log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
SEVERE: log4j:ERROR [WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)] whereas object of type
SEVERE: log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)].
SEVERE: log4j:ERROR Could not instantiate appender named "stdout".
SEVERE: log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
SEVERE: log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
SEVERE: log4j:ERROR [WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)] whereas object of type
SEVERE: log4j:ERROR "org.apache.log4j.DailyRollingFileAppender" was loaded by [WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)].
SEVERE: log4j:ERROR Could not instantiate appender named "file".
SEVERE: log4j:WARN No appenders could be found for logger (org.hibernate.annotations.common.Version).
SEVERE: log4j:WARN Please initialize the log4j system properly.
INFO: WebModule[null] ServletContext.log():No Spring WebApplicationInitializer types detected on classpath
WARNING: JSF1022: [true/false] Invalid value 'javax.faces.PARTIAL_STATE_SAVING' for configuration option 'true|false'. Valid values are 'true|false'. Falling back to the default of 'true'.
INFO: Initializing Mojarra 2.2.0 ( 20130502-2118 https://svn.java.net/svn/mojarra~svn/tags/2.2.0@11930) for context '/AnchorFused4.03'
INFO: Monitoring jndi:/server/.../WEB-INF/faces-config.xml for modifications
我已设置以下依赖项
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
我也有休眠和弹簧依赖性 我已经从依赖项中排除了commons-logging以避免任何冲突....
log4j属性文件位于src / main / resources中,位于WEB-INF / classes / classpath下。
#Log to Console as STDOUT
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c %3x - %m%n
#Log to file FILE
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=logfile.log
log4j.appender.file.DatePattern='.'yyyy-MM-dd
log4j.appender.file.append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c %3x - %m%n
#Root Logger
log4j.rootLogger=INFO, stdout, file
我已经尝试过使用slf4j-log4j12和slf4j-simple的几种组合,但两者都产生相同的错误。
注意:我注意到如果我从maven依赖中排除jboss-logging,我就不会得到Log4j错误..但不幸的是,jboss-logging是一个hibernate-core依赖,如果没有它,应用程序就无法运行。