码迷,mamicode.com
首页 > Web开发 > 详细

ibatis + log4net 配置注意事项

时间:2014-08-26 09:38:45      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:style   os   io   文件   ar   cti   log   line   sp   

一 在web.config或app.config中配置

   

<configuration>

  <configSections>

<sectionGroup name="iBATIS">
      <section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common"/>
    </sectionGroup>
    <!--iBATIS日志配置直接放在当前文件-->
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

</configSections>
  <appSettings>

 <!--iBATIS日志配置-->
  <iBATIS>
    <logging>
      <logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net">
        <!--不能修改为file 或 file-watch,否则ibatis sql将无法抓取-->
        <arg key="configType" value="inline"/>
      </logFactoryAdapter>
    </logging>
  </iBATIS>

<log4net>
    <!--不能放到单独的log4net.config中,否则ibatis sql将无法抓取-->
    <root>
      <!--OFF > FATAL > ERROR > WARN > INFO > DEBUG > ALL-->
      <level value ="ERROR" />
      <appender-ref ref="LogALL" />
    </root>
    <appender name="LogALL" type="log4net.Appender.RollingFileAppender" >
      <file value="Log\\" />
      <appendToFile value="true" />
      <datePattern value="yyyy-MM-dd.LOG" />
      <maxSizeRollBackups value="10" />
      <rollingStyle value="Date" />
      <maximumFileSize value="1MB" />
      <staticLogFileName value="false" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %p %u %c %l %m %n" />
      </layout>
    </appender>
    <logger name="IBatisNet.DataMapper.Commands.DefaultPreparedCommand">
      <level value="DEBUG" />
    </logger>
    <logger name="IBatisNet.DataMapper.Configuration.Cache.CacheModel">
      <level value="DEBUG" />
    </logger>
    <logger name="IBatisNet.DataMapper.LazyLoadList">
      <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.DaoSession">
      <level value="DEBUG" />
    </logger>
    <logger name="IBatisNet.DataAccess.Configuration.DaoProxy">
      <level value="DEBUG" />
    </logger>
    <logger name="IBatisNet.DataMapper.Configuration.Statements.PreparedStatementFactory">
      <level value="DEBUG" />
    </logger>
    <logger name="IBatisNet.DataMapper.Commands.IPreparedCommand">
      <level value="DEBUG" />
    </logger>
  </log4net>
  <!--iBATIS日志配置-->
</configuration>

 

ibatis + log4net 配置注意事项

标签:style   os   io   文件   ar   cti   log   line   sp   

原文地址:http://www.cnblogs.com/eugenewu0808/p/3936428.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!