- Link the App.config file of the service or executable to the UnitTests project
- Include a
ILog sLogger = LogManager.GetLogger(typeof(IsmClientWatchdog));
in the test class, even thought sLogger is never used therein. - Add
[assembly: log4net.Config.XmlConfigurator(Watch=true)]
to the UnitTests project's AssemblyInfo.cs
XmlConfigurator.Configure()[Original post]
I found a nice way to be able to see the log4net output when unit testing under TestDriven.NET:
log4net.Appender.ConsoleAppender app;
[TestFixtureSetUp]
public void Init()
{
app = new log4net.Appender.ConsoleAppender();
app.Layout = new log4net.Layout.PatternLayout("%d %C{1} [%-5p] : %m%n");
app.Threshold = log4net.Core.Level.All;
log4net.Config.BasicConfigurator.Configure(app);
}
[TestFixtureTearDown]
public void Dispose()
{
app.Threshold = log4net.Core.Level.Off;
}
No comments:
Post a Comment