Log4Net Logging Output with ReSharper Test Runner - Config

This post assumes you know what Log4Net is and how to configure it and you are using ReSharper and you are unit testing your code. If you don't its time to learn something new..

If you want your log lines to show up in resharper test output window, you need to add  TraceAppender to the appenders list.

  <appender name="NetTraceAppender" type="log4net.Appender.TraceAppender, log4net">
      <layout type="log4net.Layout.PatternLayout,log4net">
        <param name="ConversionPattern" value="%d [%t] %-5p - %m%n" />
      </layout>
    </appender>
and the use it under root tag.

<root>
      <level value="Debug"/>

      <appender-ref ref="NetTraceAppender" />
      <appender-ref ref="RollingFileAppender" />
    </root>
If using iBatis, and you only want to see the processed SQL query, include following also.

<!-- Print only messages of level DEBUG or above in the packages -->
    <logger name="IBatisNet.DataMapper.Commands.DefaultPreparedCommand">
      <level value="DEBUG" />
    </logger>
    <logger name="IBatisNet.DataMapper.Configuration.Cache.CacheModel">
      <level value="OFF" />
    </logger>
    <logger name="IBatisNet.DataMapper.LazyLoadList">
      <level value="OFF" />
    </logger>
    <logger name="IBatisNet.DataMapper.SqlMapSession">
      <level value="OFF" />
    </logger>
    <logger name="IBatisNet.Common.Transaction.TransactionScope">
      <level value="OFF" />
    </logger>
    <logger name="IBatisNet.DataAccess.DaoSession">
      <level value="OFF" />
    </logger>
    <logger name="IBatisNet.DataAccess.Configuration.DaoProxy">
      <level value="OFF" />
    </logger>
    <logger name="IBatisNet.DataMapper.Configuration.Statements.PreparedStatementFactory">
      <level value="OFF" />
    </logger>
    <logger name="IBatisNet.DataMapper.Commands.IPreparedCommand">
      <level value="OFF" />
    </logger>

Popular posts from this blog

Print a receipt using a Thermal Printer with C#.NET

Automatic redirect upon session timeout using ASP.NET MVC and Javascript

Complex Master-Detail Form using Knockout.js and ASP.NET MVC