【问题标题】:Cannot get logging output from iBATIS.NET无法从 iBATIS.NET 获取日志记录输出
【发布时间】:2011-11-11 15:41:50
【问题描述】:

我的应用程序正在使用 iBATIS.NET 数据映射器版本 1.6.3。最近的修改导致了 SqlException,我想查看它正在尝试执行的查询,所以我在 app.config 中添加了以下内容:

<configSections>
    <sectionGroup name="iBATIS">
        <section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common"/>
    </sectionGroup>
</configSections>

<iBATIS>
    <logging>
        <loggingFactoryAdapter type="IBatisNet.Common.Logging.Impl.TraceLoggerFA, IBatisNet.Common">
            <arg key="logLevel" value="All"/>
        </loggingFactoryAdapter>
    </logging>
</iBATIS>

<system.diagnostics>
    <trace autoflush="true" indentsize="4">
        <listeners>
            <add name="textFileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log"/>
        </listeners>
    </trace>
</system.diagnostics>

但是,我没有得到任何输出。作为健全性检查,我添加了一些对 Trace.WriteLine() 的调用,并且这些调用按预期附加到了日志文件中。

我是否缺少某些元素来打开日志记录?

【问题讨论】:

  • 我遇到了类似的问题。 ibatis.apache.org/docs/dotnet/datamapper/ch04s05.html 有文档,但我仍然无法获得查询输出。你有没有想过这个? ——马修
  • 很遗憾,没有。我从来没有让这个工作。
  • 好的,如果我得到它的工作,我会发布一个答案。

标签: ibatis.net


【解决方案1】:

迟到总比从不好 - 对我来说,原因是缺少对 IBatisNet.Common.Logging.Log4Net 的参考。根据https://ibatis.apache.org/docs/dotnet/datamapper/ch04s02.html 的说法,它是一个单独的DLL,您需要引用它才能将Log4Net 与iBatis 一起使用。

【讨论】:

    【解决方案2】:

    相当老的线程,但是像我这样的人使用这个很棒的 ibatis.net 库。因此,如果您遇到此问题,请在您的 app.config/web.config 中检查部分是否提到了 log4net 依赖项。

    把下面的xml节点放在那里(注意log4net版本是今天最新的)

    <dependentAssembly>
       <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
       <bindingRedirect oldVersion="0.0.0.0-1.2.13.0" newVersion="1.2.13.0" />
    </dependentAssembly>
    

    【讨论】:

      猜你喜欢
      • 2020-11-28
      • 2013-09-18
      • 2021-03-22
      • 1970-01-01
      • 2015-01-22
      • 2021-05-11
      • 2019-04-29
      • 2014-12-25
      • 1970-01-01
      相关资源
      最近更新 更多