Unit testing 在单元测试下运行时,log4net找不到线程id

Unit testing 在单元测试下运行时,log4net找不到线程id,unit-testing,log4net,mstest,Unit Testing,Log4net,Mstest,我有log4net,它写的条目如下: <conversionPattern value="[%date{yyyy-MM-dd HH:mm:ss}] [%property{machineName}] [%property{pid}] [%thread] [%-5level]: %message%newline"/> 所以很明显,log4net在测试运行程序中使用时会感到困惑。如果我正常运行应用程序,那么我会得到一个正常的线程id 有人知道解决方法吗?我正在使用MSTest。MSTes

我有log4net,它写的条目如下:

<conversionPattern value="[%date{yyyy-MM-dd HH:mm:ss}] [%property{machineName}] [%property{pid}] [%thread] [%-5level]: %message%newline"/>
所以很明显,log4net在测试运行程序中使用时会感到困惑。如果我正常运行应用程序,那么我会得到一个正常的线程id

有人知道解决方法吗?我正在使用MSTest。MSTest测试运行程序和R#测试运行程序也会出现相同的行为

提前感谢您阅读我的问题


George

在单元测试项目中添加对log4net的引用可能会起到作用(请参阅)


话虽如此,在这种情况下,您可能不需要登录(除非这些是真正的集成测试),因此最好使用一个而不是真正的logger对象。

为什么需要登录单元测试???
Agent: adapter run thread for test 'Log4NetLogger_TestLoggingMachineNamePrinted' with id '84e27809-f2b8-45b4-a2e1-ce305d20bc0c'