在 NUnit TestRunner 中运行测试时如何停止 log4net 记录
首先让我解释一下我的场景:
- 我有大约 2000 个测试要运行,在 NUnit 中大约需要 30 秒
- 我想找出
- 打开 Ants Profiler 并让它分析 NUnit TestRunner 并加载我的测试 dll 所花费的时间进入 TestRunner
- ,然后运行测试...
但是,在分析的同时运行测试需要很多更长的时间(运行所有测试大约需要 5 分钟,而不是 30 秒)。当我查看 Ants Profiler 中的计时时,似乎在很多地方都调用了 log4net,这似乎占用了时间。
所以,这是我的问题:当我以这种方式运行测试时,如何停止 log4net 记录内容?
我可以找到 3 个配置文件:
- 在 test dll 文件夹中,有一个 config.log4net 文件。我已将
在那里,并删除了所有附加程序部分 - 在测试运行程序文件夹中,有一个 nunit.exe.config 和一个 nunit-console.exe.config 文件 - 我已将
在这两个方面。 - 我在 ants profiler 文件夹中找不到任何可使用的配置文件。
这些似乎都不起作用,查看配置文件结果我可以看到 log4net 被调用,并且它肯定正在调用方法来输出日志记录信息。
Let me explain my scenario first:
- I have around 2000 tests to run, which take about 30 seconds in NUnit
- I want to find out what's taking the time
- I open Ants Profiler, and get it to profile the NUnit TestRunner, and load my test dll into the TestRunner
- I then run the tests...
However, running the tests whilst profiling takes a lot longer (about 5 minutes to run all the tests, rather than 30 seconds). When i look through the timings in Ants Profiler, it seems log4net is being called in a lot of places, which seems to be taking up the time.
So, this is my question: how do i stop log4net logging stuff when i'm running the tests in this manner?
I can find 3 config files:
- In the test dll folder, there's a config.log4net file. I've put <level value="OFF" /> in there, and deleted all the appender sections
- In the test runner folder, there's a nunit.exe.config, and a nunit-console.exe.config file - i've put <level value="OFF" /> in both of those.
- I can't find any config files to play with in the ants profiler folder.
None of this seems to work, looking through the profile results i can see log4net being called, and it's definitely calling methods to output the logging information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在测试设置中,获取根记录器并将其日志级别设置为“关闭”。
In the test setup, get the root logger and set it's log level to OFF.