This extension allows you to derive your tests from LoggedTestBase which will automatically link NLog with XUnitTestOutputHelper
By adding nlog.config to your test project with this content
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
throwExceptions="true">
<extensions>
<add assembly="Amusoft.XUnit.NLog.Extensions" />
</extensions>
<variable name="loggingLayout" value="${time}|${level:uppercase=true}|${logger}|${message}"/>
<targets async="false">
<target xsi:type="XUnitOutputTarget"
layout="${loggingLayout}"
name="XUnitTestOutput" />
<target xsi:type="Console" name="console"/>
</targets>
<rules>
<logger name="*" minlevel="Warn" writeTo="console,XUnitTestOutput" />
</rules>
</nlog>
you will now receive log output from your actual library classes
Package | Line Rate | Branch Rate | Health |
---|---|---|---|
Amusoft.XUnit.NLog.Extensions | 100% | 100% | ✔ |
Summary | 100% (6 / 6) | 100% (0 / 0) | ✔ |
Minimum allowed line rate is 85%