0

我的应用程序使用的是 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() 的调用,这些调用按预期附加到了日志文件中。

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

4

2 回答 2

0

相当老的线程,但是像我这样的人使用这个很棒的 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>
于 2015-10-31T18:45:01.730 回答
0

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

于 2021-01-07T14:46:52.380 回答