log4j.xml经典写法(配合ssm)

log4j.xml经典写法代码:

<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
	debug="false">
	<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%d %-5p [%t] %-5p [%c-%L] - %m%n" />
		</layout>
	</appender>
	<appender name="file" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="../logs/uet.log" />
		<param name="Append" value="true" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%d %-5p [%t] %-5p [%c-%L] - %m%n" />
		</layout>
	</appender>
	<appender name="performace" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="../logs/performace.log" />
		<param name="Append" value="true" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%d %-5p [%t] %-5p [%c-%L] - %m%n" />
		</layout>
	</appender>
	<appender name="exception" class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="../logs/exception.log" />
		<param name="Append" value="true" />
		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%d %-5p [%t] %-5p [%c-%L] - %m%n" />
		</layout>
	</appender>
	<appender name="EMAIL" class="org.apache.log4j.net.SMTPAppender">    
		 <param name="BufferSize" value="1" />
		 <param name="SMTPHost" value="smtp.qq.com" />
		 <param name="SMTPUsername" value="278804309" />
		 <param name="SMTPPassword" value="dotachen" />
		 <param name="From" value="278804309@qq.com" />
		 <param name="To" value="cgp841016@163.com" />
		 <param name="Subject" value="错误邮件发送" />
		 <param name="LocationInfo" value="false" />
		 <param name="SMTPDebug" value="false" />
		 <layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%d %-5p [%t] %-5p [%c-%L] - %m%n" />
		</layout>
	</appender>
	<!--  
	<logger name="EmailError" additivity="false">
		<level class="org.apache.log4j.Level" value="WARN" />
		<appender-ref ref="exception" />
		<appender-ref ref="EMAIL" /> 
	</logger>
	<logger name="error" additivity="false">
		<level class="org.apache.log4j.Level" value="WARN" />
		<appender-ref ref="exception" />
		<appender-ref ref="stdout" />
	</logger>
	<logger name="performace" additivity="true">
		<level class="org.apache.log4j.Level" value="OFF" />
		<appender-ref ref="performace" />
	</logger>
	<logger name="atomikos" additivity="true">
		<level class="org.apache.log4j.Level" value="OFF" />
		<appender-ref ref="file" />
	</logger>
	<logger name="org.apache.ibatis" additivity="false">
		<level class="org.apache.log4j.Level" value="WARN" />
		<appender-ref ref="stdout" />
		<appender-ref ref="file" />
	</logger>
	<logger name="java.sql" additivity="false">
		<level class="org.apache.log4j.Level" value="WARN" />
		<appender-ref ref="stdout" />
		<appender-ref ref="file" />
	</logger>
	<logger name="org.mybatis.spring" additivity="false">
		<level class="org.apache.log4j.Level" value="OFF" />
		<appender-ref ref="stdout" />
		<appender-ref ref="file" />
	</logger>
	-->
	<appender name="IBatis" class="org.apache.log4j.ConsoleAppender"> 
	   <layout class="org.apache.log4j.PatternLayout"> 
	      <param name="ConversionPattern" value="%-4r [%t] %-5p %c %x - %m%n" /> 
	   </layout> 
	   <filter class="org.apache.log4j.varia.LevelRangeFilter"> 
	      <param name="LevelMin" value="DEBUG" /> 
	      <param name="LevelMax" value="DEBUG" /> 
	   </filter>
	</appender> 
	
	<logger name="com.ibatis" additivity="true"> 
	   <level value="DEBUG" /> 
	</logger> 
	<logger name="java.sql.Connection" additivity="true"> 
	   <level value="DEBUG" /> 
	</logger> 
	<logger name="java.sql.Statement" additivity="true"> 
	   <level value="DEBUG" /> 
	</logger> 
	<logger name="java.sql.PreparedStatement" additivity="true"> 
	   <level value="DEBUG" /> 
	   <appender-ref ref="IBatis" /> 
	</logger> 
	<logger name="java.sql.ResultSet" additivity="true"> 
	   <level value="DEBUG" /> 
	   <appender-ref ref="IBatis" /> 
	</logger>
	<!-- BEGIN 注意这行不可删掉 方便开发测试共用数据库环境 -->
	<!-- BEGIN 注意这行不可删掉 方便开发测试共用数据库环境 -->
	<category name="com.uet.platform.user.action">
		<priority value="INFO" />
		<appender-ref ref="file" />
	</category>
	<!-- END 注意这行不可删掉 方便开发测试共用数据库环境 -->
	 
	<category name="com.uet.framework.cache">
		<priority value="ERROR" />
		<appender-ref ref="file" />
	</category>
	<category name="com.uet.framework.config">
		<priority value="ERROR" />
		<appender-ref ref="file" />
	</category>
	<category name="com.uet">
		<priority value="INFO" />
		<appender-ref ref="file" />
		<appender-ref ref="stdout" />
	</category>
	<category name="org.springframework">
		<priority value="ERROR" />
		<appender-ref ref="file" />
	</category>
	<category name="com.opensymphony.xwork2">
		<priority value="ERROR" />
		<appender-ref ref="file" />
	</category>
	<category name="com.opensymphony.xwork2.util.finder.ClassFinder">
		<priority value="ON" />
	</category>
	<root>
		<priority value="ERROR" />
		<appender-ref ref="stdout" />
	</root>
	
</log4j:configuration> 



企业信息化
分享到:
共 0 条  此列表为空  当前1/1页

© 2014 究问社区 copyRight 豫ICP备13003319号-1