如何为 NLog 编写一个以毫秒为单位输出时间的布局11:32:08:123
?我使用${date:format=yyyy-MM-dd HH\:mm\:ss}
但我的日志需要更多的时间精度。
问问题
40655 次
3 回答
95
${date:format=yyyy-MM-dd HH\:mm\:ss.fff}
According to the NLog documentation, you can use C# DateTime format string.
This is a pretty good reference for DateTime format strings: http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm
于 2010-09-24T20:57:07.957 回答
12
${longdate}
hariyott 建议的格式的另一种替代方法是使用 ${longdate} 渲染器。它应该自动为您提供所需的精度。
于 2014-01-06T11:34:31.993 回答
11
另一种替代解决方案是使用 ISO 8601 格式“1998-02-23T14:23:05.555”。这种格式与 sql server 的语言无关。
${date:format=yyyy-MM-ddTHH\:mm\:ss.fff}
于 2014-05-28T08:54:23.347 回答