我有一个使用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上搜索过,但找不到一个简单的设置示例。有什么建议吗?