Skip to content

Instantly share code, notes, and snippets.

@benbrandt22
Last active August 29, 2015 14:04
Show Gist options
  • Save benbrandt22/da09f6fa858c5370bafc to your computer and use it in GitHub Desktop.
Save benbrandt22/da09f6fa858c5370bafc to your computer and use it in GitHub Desktop.
Logging to MSTest Unit Test Output with Common.Logging
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
<arg key="level" value="TRACE" />
<arg key="showLogName" value="true" />
<arg key="showDataTime" value="true" />
<arg key="dateTimeFormat" value="HH:mm:ss.fff" />
</factoryAdapter>
</logging>
</common>
</configuration>
public int AddIntegers(int a, int b)
{
var log = LogManager.GetLogger("LoggingTo.UnitTestOutput.Demo");
log.DebugFormat("Adding integers {0} and {1}...", a, b);
int result = (a + b);
log.DebugFormat("Sum = {0}", result);
return result;
}
[TestMethod]
public void AddIntegersTest() {
int expected = 22;
int actual = AddIntegers(10, 12);
Assert.AreEqual(expected, actual);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment