IBatis.Net学习笔记七--日志处理

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介:
IBatis.Net中提供了方便的日志处理,可以输出sql语句等调试信息。

常用的有两种:
1、输出到控制台:
   < configSections >
    
< sectionGroup name = " iBATIS " >
      
< section name = " logging "  type = " IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common "   />
    
</ sectionGroup >
  
</ configSections >

< iBATIS >
    
< logging >
      
< logFactoryAdapter type = " IBatisNet.Common.Logging.Impl.TraceLoggerFA, IBatisNet.Common " >
        
< arg key = " showLogName "  value = " true "   />
        
< arg key = " showDataTime "  value = " true "   />
        
< arg key = " level "  value = " ALL "   />
        
< arg key = " dateTimeFormat "  value = " yyyy/MM/dd HH:mm:ss:SSS "   />
      
</ logFactoryAdapter >
    
</ logging >
  
</ iBATIS >

2、利用log4net输出到文件:
   < configSections >
    
< sectionGroup name = " iBATIS " >
      
< section name = " logging "  type = " IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common "   />
    
</ sectionGroup >
    
< section name = " log4net "  type = " log4net.Config.Log4NetConfigurationSectionHandler, log4net "   />
  
</ configSections >

   < iBATIS >
    
< logging >
      
< logFactoryAdapter type = " IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net " >
        
< arg key = " configType "  value = " inline "   />
      
</ logFactoryAdapter >
    
</ logging >
  
</ iBATIS >

   < log4net >
    
<!--  Define some output appenders  -->
    
< appender name = " RollingLogFileAppender "  type = " log4net.Appender.RollingFileAppender " >
      
< param name = " File "  value = " f:\log.txt "   />
      
< param name = " AppendToFile "  value = " true "   />
      
< param name = " MaxSizeRollBackups "  value = " 2 "   />
      
< param name = " MaximumFileSize "  value = " 100KB "   />
      
< param name = " RollingStyle "  value = " Size "   />
      
< param name = " StaticLogFileName "  value = " true "   />
      
< layout type = " log4net.Layout.PatternLayout " >
        
< param name = " Header "  value = " [Header]\r\n "   />
        
< param name = " Footer "  value = " [Footer]\r\n "   />
        
< param name = " ConversionPattern "  value = " %d [%t] %-5p %c [%x] - %m%n "   />
      
</ layout >
    
</ appender >
    
< appender name = " ConsoleAppender "  type = " log4net.Appender.ConsoleAppender " >
      
< layout type = " log4net.Layout.PatternLayout " >
        
< param name = " ConversionPattern "  value = " %d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n "   />
      
</ layout >
    
</ appender >

    
<!--  Set root logger level to ERROR and its appenders  -->
    
< root >
      
< level value = " DEBUG "   />
      
< appender - ref   ref = " RollingLogFileAppender "   />
      
< appender - ref   ref = " ConsoleAppender "   />
    
</ root >

    
<!--  Print only messages of level DEBUG or above  in  the packages  -->
    
< logger name = " IBatisNet.DataMapper.Configuration.Cache.CacheModel " >
      
< level value = " DEBUG "   />
    
</ logger >
    
< logger name = " IBatisNet.DataMapper.Configuration.Statements.PreparedStatementFactory " >
      
< level value = " DEBUG "   />
    
</ logger >
    
< logger name = " IBatisNet.DataMapper.LazyLoadList " >
      
< level value = " DEBUG "   />
    
</ logger >
    
< logger name = " IBatisNet.DataAccess.DaoSession " >
      
< level value = " DEBUG "   />
    
</ logger >
    
< logger name = " IBatisNet.DataMapper.SqlMapSession " >
      
< level value = " DEBUG "   />
    
</ logger >
    
< logger name = " IBatisNet.Common.Transaction.TransactionScope " >
      
< level value = " DEBUG "   />
    
</ logger >
    
< logger name = " IBatisNet.DataAccess.Configuration.DaoProxy " >
      
< level value = " DEBUG "   />
    
</ logger >
  
</ log4net >


    本文转自永春博客园博客,原文链接: http://www.cnblogs.com/firstyi/archive/2007/08/22/865028.html ,如需转载请自行联系原作者

相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
数据可视化 搜索推荐 API
七、.net core(.NET 6)使用Serilog进行配置和实现日志记录
使用Serilog来实现日志记录先安装Serilog六件套神装包:
1939 0
七、.net core(.NET 6)使用Serilog进行配置和实现日志记录
|
搜索推荐 API 数据库
ElasticSearch入门 附.Net Core例子
1.什么是ElasticSearch? Elasticsearch是基于Lucene的搜索引擎。它提供了一个分布式,支持多租户的全文搜索引擎,它具有HTTP Web界面和无模式JSON文档。 Elasticsearch是用Java开发的,根据Apache许可条款作为开源发布。
2767 0
|
SQL Oracle 关系型数据库