无法从iBATIS.NET获取日志输出

时间:2011-09-06 20:35:50

标签: ibatis.net

我的应用程序使用的是iBATIS.NET Data Mapper 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()调用,并按预期将它们附加到日志文件中。

我是否遗漏了一些打开日志记录的元素?

2 个答案:

答案 0 :(得分: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>

答案 1 :(得分:0)

迟到总比没有好 - 对我来说,原因是缺少对 IBatisNet.Common.Logging.Log4Net 的参考。根据{{​​3}},它是您需要引用的单独 DLL,以便能够在 iBatis 中使用 Log4Net。

相关问题