【发布时间】:2011-01-11 10:06:34
【问题描述】:
我正在尝试使用 Log4j 作为 Spring 框架的一部分, 据我了解,通过使用适当的 bean 系统应该映射代码中可访问的单例实例 同时将日志记录深度自动映射到类
类似于在
中正常使用Log4JLogger log = Logger.getLogger(getClass());
我一直在使用下面的 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>conf\log4j.xml</value>
</list>
</property>
</bean>
但我无法将此 bean 映射到给定类中的特定成员 我也无法通过@autowired 使用它
如果有更好的集成 Log4j 和 Spring 的方法,请告诉我
最好的问候
标记
【问题讨论】: