Spring log 注入

悬赏:5 发布时间:2008-07-06 提问人:timcat (初级程序员)

如何是用Spring方式生成的log,取得类名

采纳的答案

2008-07-07 wangxin0072000 (高级程序员)

首先在web.xml中:
<listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
 	 </listener>
  <context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>classpath:log4j.xml</param-value>
  </context-param>

之后在log4j.xml中
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern"
				value="%p - %C{1}.%M(%L) | %m%n" />
		</layout>
	</appender>

试试吧

提问者对于答案的评价:
谢谢