NLog layout map to conversionPattern with log4net

log4net

  <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss.fffzzz} %-5p [%t]: %m%n" />
      </layout>

 

https://github.com/NLog/NLog/wiki/Layouts

Layouts are one of the attributes of most targets. The layout attribute is used to determine the format of the information to be logged. Many pre-defined 'macros' or Layout renderers exist. In the below example ${machinename} is an example of a layout renderer.

Default Layout

If a target has the layout attribute, you may define a custom layout. If you do not specify a layout, the default layout is used. The default layout is:

${longdate}|${level:uppercase=true}|${logger}|${message}

 

NLog time formatting

${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

 

posted @ 2020-07-03 14:11  ChuckLu  阅读(188)  评论(0编辑  收藏  举报