Layout Renderers

Layout Renderers

NLog package Version

  • ${activityid} - Puts into log a System.Diagnostics trace correlation id.
  • ${all-event-properties} - Log all event context data.
  • ${appdomain} - Current app domain.
  • ${assembly-version} - The version of the executable in the default application domain.
  • ${basedir} - The current application domain's base directory.
  • ${callsite} - The call site (class name, method name and source information).
  • ${callsite-linenumber} - The call site source line number.
  • ${counter} - A counter value (increases on each layout rendering).
  • ${date} - Current date and time.
  • ${document-uri} - URI of the HTML page which hosts the current Silverlight application.
  • ${environment} - The environment variable.
  • ${event-properties} - Log event properties data - rename of ${event-context}.
  • ${exception} - Exception information provided through a call to one of the Logger.*Exception() methods.
  • ${file-contents} - Renders contents of the specified file.
  • ${gc} - The information about the garbage collector.
  • ${gdc} - Global Diagnostic Context item. Dictionary structure to hold per-application-instance values.
  • ${guid} - Globally-unique identifier (GUID).
  • ${identity} - Thread identity information (name and authentication information).
  • ${install-context} - Installation parameter (passed to InstallNLogConfig).
  • ${level} - The log level.
  • ${literal} - A string literal.
  • ${log4jxmlevent} - XML event description compatible with log4j, Chainsaw and NLogViewer.
  • ${logger} - The logger name.
  • ${longdate} - The date and time in a long, sortable format yyyy-MM-dd HH:mm:ss.ffff.
  • ${machinename} - The machine name that the process is running on.
  • ${mdc} - Mapped Diagnostics Context - a thread-local structure.
  • ${mdlc} - Async Mapped Diagnostics Context - a thread-local structure.
  • ${message} - The formatted log message.
  • ${ndc} - Nested Diagnostics Context - a thread-local structure.
  • ${newline} - A newline literal.
  • ${nlogdir} - The directory where NLog.dll is located.
  • ${performancecounter} - The performance counter.
  • ${processid} - The identifier of the current process.
  • ${processinfo} - The information about the running process.
  • ${processname} - The name of the current process.
  • ${processtime} - The process time in format HH:mm:ss.mmm.
  • ${qpc} - High precision timer, based on the value returned from QueryPerformanceCounter() optionally converted to seconds.
  • ${registry} - A value from the Registry.
  • ${shortdate} - The short date in a sortable format yyyy-MM-dd.
  • ${sl-appinfo} - Information about Silverlight application.
  • ${specialfolder} - System special folder path (includes My Documents, My Music, Program Files, Desktop, and more).
  • ${stacktrace} - Stack trace renderer.
  • ${tempdir} - A temporary directory.
  • ${threadid} - The identifier of the current thread.
  • ${threadname} - The name of the current thread.
  • ${ticks} - The Ticks value of current date and time.
  • ${time} - The time in a 24-hour, sortable format HH:mm:ss.mmm.
  • ${var} - Render variable (new in 4.1)
  • ${windows-identity} - Thread Windows identity information (username).

Wrappers

  • ${cached} - Applies caching to another layout output.
  • ${filesystem-normalize} - Filters characters not allowed in the file names by replacing them with safe character.
  • ${json-encode} - Escapes output of another layout using JSON rules.
  • ${lowercase} - Converts the result of another layout output to lower case.
  • ${onexception} - Only outputs the inner layout when exception has been defined for log message.
  • ${pad} - Applies padding to another layout output.
  • ${replace} - Replaces a string in the output of another layout with another string.
  • ${replace-newlines} - Replaces newline characters with another string.
  • ${rot13} - Decodes text "encrypted" with ROT-13.
  • ${trim-whitespace} - Trims the whitespace from the result of another layout renderer.
  • ${uppercase} - Converts the result of another layout output to upper case.
  • ${url-encode} - Encodes the result of another layout output for use with URLs.
  • ${when} - Only outputs the inner layout when the specified condition has been met.
  • ${whenEmpty} - Outputs alternative layout when the inner layout produces empty result.
  • ${WrapLine} - Wraps the result of another layout output at specified line length.
  • ${xml-encode} - Converts the result of another layout output to be XML-compliant.

NLog.Extended package  Version

NLog.Web package Version

External packages

External packages, not maintained by the NLog team.

Passing Custom Values to a Layout

Even though the layout renderers provide many pre-defined values, you may need to pass application specific values to your Layouts. You can pass your own values in code by adding custom properties to the event. You then retrieve the value using the ${event-properties} renderer. See the documentation for the ${event-properties} for an example.

posted on   itjeff  阅读(469)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示