IBatis.Net中提供了方便的日志处理,可以输出sql语句等调试信息。

常用的有两种:
1、输出到控制台:
IBatis.Net学习笔记七--日志处理  <configSections>
IBatis.Net学习笔记七--日志处理    
<sectionGroup name="iBATIS">
IBatis.Net学习笔记七--日志处理      
<section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common" />
IBatis.Net学习笔记七--日志处理    
</sectionGroup>
IBatis.Net学习笔记七--日志处理  
</configSections>
IBatis.Net学习笔记七--日志处理
IBatis.Net学习笔记七--日志处理
<iBATIS>
IBatis.Net学习笔记七--日志处理    
<logging>
IBatis.Net学习笔记七--日志处理      
<logFactoryAdapter type="IBatisNet.Common.Logging.Impl.TraceLoggerFA, IBatisNet.Common">
IBatis.Net学习笔记七--日志处理        
<arg key="showLogName" value="true" />
IBatis.Net学习笔记七--日志处理        
<arg key="showDataTime" value="true" />
IBatis.Net学习笔记七--日志处理        
<arg key="level" value="ALL" />
IBatis.Net学习笔记七--日志处理        
<arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:SSS" />
IBatis.Net学习笔记七--日志处理      
</logFactoryAdapter>
IBatis.Net学习笔记七--日志处理    
</logging>
IBatis.Net学习笔记七--日志处理  
</iBATIS>

2、利用log4net输出到文件:
IBatis.Net学习笔记七--日志处理  <configSections>
IBatis.Net学习笔记七--日志处理    
<sectionGroup name="iBATIS">
IBatis.Net学习笔记七--日志处理      
<section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common" />
IBatis.Net学习笔记七--日志处理    
</sectionGroup>
IBatis.Net学习笔记七--日志处理    
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
IBatis.Net学习笔记七--日志处理  
</configSections>

IBatis.Net学习笔记七--日志处理  <iBATIS>
IBatis.Net学习笔记七--日志处理    
<logging>
IBatis.Net学习笔记七--日志处理      
<logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net">
IBatis.Net学习笔记七--日志处理        
<arg key="configType" value="inline" />
IBatis.Net学习笔记七--日志处理      
</logFactoryAdapter>
IBatis.Net学习笔记七--日志处理    
</logging>
IBatis.Net学习笔记七--日志处理  
</iBATIS>

IBatis.Net学习笔记七--日志处理  <log4net>
IBatis.Net学习笔记七--日志处理    
<!-- Define some output appenders -->
IBatis.Net学习笔记七--日志处理    
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
IBatis.Net学习笔记七--日志处理      
<param name="File" value="f:\log.txt" />
IBatis.Net学习笔记七--日志处理      
<param name="AppendToFile" value="true" />
IBatis.Net学习笔记七--日志处理      
<param name="MaxSizeRollBackups" value="2" />
IBatis.Net学习笔记七--日志处理      
<param name="MaximumFileSize" value="100KB" />
IBatis.Net学习笔记七--日志处理      
<param name="RollingStyle" value="Size" />
IBatis.Net学习笔记七--日志处理      
<param name="StaticLogFileName" value="true" />
IBatis.Net学习笔记七--日志处理      
<layout type="log4net.Layout.PatternLayout">
IBatis.Net学习笔记七--日志处理        
<param name="Header" value="[Header]\r\n" />
IBatis.Net学习笔记七--日志处理        
<param name="Footer" value="[Footer]\r\n" />
IBatis.Net学习笔记七--日志处理        
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
IBatis.Net学习笔记七--日志处理      
</layout>
IBatis.Net学习笔记七--日志处理    
</appender>
IBatis.Net学习笔记七--日志处理    
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
IBatis.Net学习笔记七--日志处理      
<layout type="log4net.Layout.PatternLayout">
IBatis.Net学习笔记七--日志处理        
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n" />
IBatis.Net学习笔记七--日志处理      
</layout>
IBatis.Net学习笔记七--日志处理    
</appender>
IBatis.Net学习笔记七--日志处理
IBatis.Net学习笔记七--日志处理    
<!-- Set root logger level to ERROR and its appenders -->
IBatis.Net学习笔记七--日志处理    
<root>
IBatis.Net学习笔记七--日志处理      
<level value="DEBUG" />
IBatis.Net学习笔记七--日志处理      
<appender-ref ref="RollingLogFileAppender" />
IBatis.Net学习笔记七--日志处理      
<appender-ref ref="ConsoleAppender" />
IBatis.Net学习笔记七--日志处理    
</root>
IBatis.Net学习笔记七--日志处理
IBatis.Net学习笔记七--日志处理    
<!-- Print only messages of level DEBUG or above in the packages -->
IBatis.Net学习笔记七--日志处理    
<logger name="IBatisNet.DataMapper.Configuration.Cache.CacheModel">
IBatis.Net学习笔记七--日志处理      
<level value="DEBUG" />
IBatis.Net学习笔记七--日志处理    
</logger>
IBatis.Net学习笔记七--日志处理    
<logger name="IBatisNet.DataMapper.Configuration.Statements.PreparedStatementFactory">
IBatis.Net学习笔记七--日志处理      
<level value="DEBUG" />
IBatis.Net学习笔记七--日志处理    
</logger>
IBatis.Net学习笔记七--日志处理    
<logger name="IBatisNet.DataMapper.LazyLoadList">
IBatis.Net学习笔记七--日志处理      
<level value="DEBUG" />
IBatis.Net学习笔记七--日志处理    
</logger>
IBatis.Net学习笔记七--日志处理    
<logger name="IBatisNet.DataAccess.DaoSession">
IBatis.Net学习笔记七--日志处理      
<level value="DEBUG" />
IBatis.Net学习笔记七--日志处理    
</logger>
IBatis.Net学习笔记七--日志处理    
<logger name="IBatisNet.DataMapper.SqlMapSession">
IBatis.Net学习笔记七--日志处理      
<level value="DEBUG" />
IBatis.Net学习笔记七--日志处理    
</logger>
IBatis.Net学习笔记七--日志处理    
<logger name="IBatisNet.Common.Transaction.TransactionScope">
IBatis.Net学习笔记七--日志处理      
<level value="DEBUG" />
IBatis.Net学习笔记七--日志处理    
</logger>
IBatis.Net学习笔记七--日志处理    
<logger name="IBatisNet.DataAccess.Configuration.DaoProxy">
IBatis.Net学习笔记七--日志处理      
<level value="DEBUG" />
IBatis.Net学习笔记七--日志处理    
</logger>
IBatis.Net学习笔记七--日志处理  
</log4net>

相关文章: