【发布时间】:2013-11-20 06:20:25
【问题描述】:
我在我的应用程序中使用 NLog 日志记录机制。我面临的问题是当并发请求命中应用程序日志记录是异步完成的,我无法识别哪一行属于哪个请求。 NLog 中有没有办法将配置设置为 NLog 本身为每个请求记录一个唯一的请求 ID?
<?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">
<targets>
<!-- add your targets here -->
<target xsi:type="File" name="file" fileName="E:\IBELogs\AirAvailability\AirAvailability.log" layout="${longdate} ${uppercase:${level}} ${message}" />
</targets>
<rules>
<!-- add your logging rules here -->
<logger name="*" minlevel="Trace" writeTo="file" />
</rules>
</nlog>
【问题讨论】: