我的应用程序使用的是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()的调用,这些调用如预期的那样被附加到日志文件中。
我是不是遗漏了一些打开日志的元素?
发布于 2015-11-01 02:45:02
这是一个很老的线程,但是像我这样的人也在使用这个很棒的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>发布于 2021-01-07 22:46:52
迟做总比不做好--对我来说,原因是缺少对IBatisNet.Common.Logging.Log4Net的引用。根据https://ibatis.apache.org/docs/dotnet/datamapper/ch04s02.html的说法,它是一个单独的DLL,你需要引用它,才能在iBatis中使用Log4Net。
https://stackoverflow.com/questions/7325824
复制相似问题