如何临时禁用针对perf测试的log4net日志记录?

And*_*ott 3 .net log4net unit-testing

我有log4net记录器配置为使用我的单元测试运行,但对于一些选择单元测试作为性能测试我想禁用日志记录.如何在运行时禁用(以及稍后重新启用)日志记录,基本上覆盖了.config文件中的记录器设置?

Pre*_*gha 8

http://osdir.com/ml/windows.dotnet.log4net.user/2004-01/msg00010.html上他们推荐

要禁用所有日志记录,请将存储库的阈值级别设置为OFF:

LogManager.GetLoggerRepository().Threshold = LogManager.GetLoggerRepository().LevelMap ["OFF"];

要启用日志记录,请将阈值设置为ALL(这是默认值):

LogManager.GetLoggerRepository().Threshold = LogManager.GetLoggerRepository().LevelMap ["ALL"];