开发者

Cannot get logging output from iBATIS.NET

My application is using the iBATIS.NET Data Mapper version 1.6.3. A recent modification is causing a SqlException and I would like to see the query that it is trying to execute, so I added the following to the 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>
    开发者_Go百科        <add name="textFileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log"/>
        </listeners>
    </trace>
</system.diagnostics>

However, I am not getting any output. As a sanity check, I added a few calls to Trace.WriteLine() and those were appended to the log file as expected.

Am I missing some element to turn on logging?


Pretty old thread but there are people like me who use this awesome ibatis.net library. So, if you are facing this problem, In your app.config/web.config check to see if log4net dependency is mentioned in section.

put the following xml node in there (note that log4net version is the latest as of today)

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


Better late then never - for me the reason was in missing Reference to IBatisNet.Common.Logging.Log4Net. According to https://ibatis.apache.org/docs/dotnet/datamapper/ch04s02.html, it is a separate DLL you need to reference, to be able to use Log4Net with iBatis.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜