NLOG实时记录
NLOG real time logging
如何配置NLOG在日志文件中有实时性?
实时我的意思是执行操作的时间(更准确地说是调用日志方法的时间)。
<target name="file" xsi:type="File"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|${exception:format=toString}"
fileName="D:/Logs/${shortdate}.log" />
{longdate} 似乎是写入日志文件 date/time。
当您调用 Logger 时,它将创建一个捕获时间戳的 LogEventInfo 对象。
log.Info("Hello World"); // Captures timestamp
当使用 NLog 布局时 ${longdate}
那么它将输出捕获的原始时间戳。无论 LogEventInfo 到达最终 NLog 目标需要多长时间,它都会始终打印捕获的时间戳。
您在精度或延迟方面遇到的任何问题都可能是由默认时间源引起的:
https://github.com/NLog/NLog/wiki/Time-Source
使用 KeepFileOpen=true
和 ConcurrentWrites=false
:
可能可以解决 NLog FileTarget 性能方面的任何问题
如何配置NLOG在日志文件中有实时性? 实时我的意思是执行操作的时间(更准确地说是调用日志方法的时间)。
<target name="file" xsi:type="File"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|${exception:format=toString}"
fileName="D:/Logs/${shortdate}.log" />
{longdate} 似乎是写入日志文件 date/time。
当您调用 Logger 时,它将创建一个捕获时间戳的 LogEventInfo 对象。
log.Info("Hello World"); // Captures timestamp
当使用 NLog 布局时 ${longdate}
那么它将输出捕获的原始时间戳。无论 LogEventInfo 到达最终 NLog 目标需要多长时间,它都会始终打印捕获的时间戳。
您在精度或延迟方面遇到的任何问题都可能是由默认时间源引起的:
https://github.com/NLog/NLog/wiki/Time-Source
使用 KeepFileOpen=true
和 ConcurrentWrites=false
: