我正在从 Resharper 运行 NUnit 测试。我想跟踪执行过程,所以我的问题是在哪里可以找到我的应用程序生成的日志?
我使用 NLog,记录器输出路径是相对的,例如logs\mylog.txt
.
我的当前项目有类似的设置,对于单元测试,我的 NLog 输出到 \UnitTests\bin\Debug\Logs。记录器在 NLog.config 中设置如下(这会生成每日日志文件):
<target name="FileLog" xsi:type="File" fileName="${basedir}/logs/${shortdate}_log.txt"
如果您根本没有从 NLog 获得任何输出,请尝试将 throwExceptions、internalLogLevel 和 internalLogFile 属性添加到您的 NLog.config,如下所示:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
throwExceptions="true"
internalLogLevel="Debug"
internalLogFile="nlog_log.log">
我意识到这是一个老问题,但万一你还没有找到答案,我想看看这是否有帮助。