使用log4net记录ibatis.net的SQL动态查询语句

1. 在web.config或app.config中添加如下配置

web.config
<?xml version="1.0"?>
<configuration>
    
<configSections>
        
<sectionGroup name="iBATIS">
            
<section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common"/>
        
</sectionGroup>
    
</configSections>
    
<iBATIS>
        
<logging>
            
<logFactoryAdapter
                
type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net">
                
<arg key="configType" value="file-watch"/>
                
<arg key="configFile" value="log4net.xml" />
            
</logFactoryAdapter>
        
</logging>
    
</iBATIS>
</configuration>

2. 添加log4net.xml配置文件

<?xml version="1.0" encoding="utf-8" ?>
<log4net>
    
<appender name="FileAppender" type="log4net.Appender.FileAppender">
        
<file value="log.txt"/>
        
<appendToFile value="true"/>
        
<layout type="log4net.Layout.PatternLayout">
            
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
        
</layout>
    
</appender>
    
<root>
        
<level value="DEBUG"/>
        
<appender-ref ref="FileAppender"/>
    
</root>
</log4net>
3. 添加对IBatisNet.Common.Logging.Log4Net.dll和log4net.dll的引用
posted @ 2009-03-23 17:05  张志敏  阅读(2775)  评论(5编辑  收藏  举报