【发布时间】:2011-03-24 04:19:17
【问题描述】:
我有一个要登录的 maven 和 spring 应用程序。我热衷于使用 SLF4J。
我想把我所有的配置文件放到一个目录 {classpath}/config 中,包括 log4j.xml,然后使用 spring bean 初始化。
例如
<bean id="log4jInitialization" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="org.springframework.util.Log4jConfigurer"/>
<property name="targetMethod" value="initLogging"/>
<property name="arguments">
<list>
<value>classpath:config/log4j.xml</value>
</list>
</property>
</bean>
但是我得到了这个警告并且没有记录。
log4j:WARN 找不到记录器的附加程序(org.springframework.context.support.ClassPathXmlApplicationContext)。 log4j:WARN 请正确初始化 log4j 系统。 log4j:WARN 请参阅http://logging.apache.org/log4j/1.2/faq.html#noconfig 了解更多信息。
我在 Google 上四处搜索,但找不到一个简单的设置示例。有什么想法吗?
【问题讨论】:
-
我猜。如果您尝试完整路径
C:/config/log4j.xml ,它的工作方式是否有所不同 -
不。硬编码没有帮助。 =(
标签: java spring logging log4j slf4j