对于我的一个应用程序,我遇到了弹簧3的log4j和appender的问题.确切的错误警告消息是"log4j:WARN没有为logger找到appender(org.springframework.test.context.support.DependencyInjectionTestExecutionListener).log4j :WARN请正确初始化log4j系统."
我用log4j阅读了有关spring配置的信息,但是我没有成功克服这个问题.通过log4j进行日志记录正在运行,但使用该WARN消息.
这是我对log4j和spring的pom配置 - 这是相当长的配置.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>com.springsource.slf4j.api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>com.springsource.slf4j.org.apache.commons.logging</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>com.springsource.slf4j.log4j</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.log4j</groupId>
<artifactId>com.springsource.org.apache.log4j</artifactId>
<version>1.2.15</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
另外,我还有一个与日志相关的内容 - 排除了弹簧核和弹簧上下文的公共日志记录.
这是web.xml配置:
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:META-INF/properties/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
Run Code Online (Sandbox Code Playgroud)
这是log4j.properties配置:
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.rootLogger=DEBUG, stdout, …Run Code Online (Sandbox Code Playgroud) 我想用log4j在Sfl4j上记录Morphia。从Morphia的文档中:
在您的应用程序开始时添加它。静态完成一次。MorphiaLoggerFactory.registerLogger(SLF4JLoggerImplFactory.class);
我无法为上述声明创建必要的bean来完成该工作。