当我使用 NLog 记录到跟踪目标类型时,它仅在级别为Trace或时才能正常工作Debug。如果是Info, Warn, 或Error,它会在我的布局之前添加额外的信息。如果级别是Fatal,我会收到一个弹出窗口,抱怨断言失败,并且它在输出中也这么说。跟踪目标是否被窃听?程序.csusing System;namespace TraceLoggingTest{ class Program { private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); static void Main(string[] args) { logger.Trace("Hello Trace"); logger.Debug("Hello Debug"); logger.Info("Hello Info"); logger.Warn("Hello Warn"); logger.Error("Hello Error"); logger.Fatal("Hello Fatal"); Console.ReadLine(); NLog.LogManager.Shutdown(); } }}配置文件<?xml version="1.0" encoding="utf-8" ?><nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" autoReload="true" throwExceptions="false" internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"> <targets> <target name="logTrace" xsi:type="Trace" layout="${message}" /> </targets> <rules> <logger name="*" minlevel="Trace" writeTo="logTrace" /> </rules></nlog>预期输出Hello TraceHello DebugHello InfoHello WarnHello ErrorHello Fatal实际产量Hello TraceHello DebugTraceLoggingTest.exe Information: 0 : Hello InfoTraceLoggingTest.exe Warning: 0 : Hello WarnTraceLoggingTest.exe Error: 0 : Hello Error---- DEBUG ASSERTION FAILED -------- Assert Short Message ----Hello Fatal---- Assert Long Message ----
1 回答
- 1 回答
- 0 关注
- 221 浏览
添加回答
举报
0/150
提交
取消