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



我的应用程序使用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.net库。所以,如果你正面临这个问题,在你的app.config/web。配置检查是否在小节中提到了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>

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

最新更新