https://github.com/nlog/NLog/wiki/Layout-Renderers

Layout renderers are template macros that are used in Layouts.

NLog supports creating custom layout renderers. For more information, see: Extending NLog

Layout Renderers

NLog package

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

NLog.Web package

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.

[转]NLog Layout Renderers ${}的更多相关文章

  1. Nlog Layout

    Nlog.config <targets>     <target type="Console" name="trace" layout=&q ...

  2. Layout Renderers

    Layout Renderers NLog package ${activityid} - Puts into log a System.Diagnostics trace correlation i ...

  3. NLog官方文档

    NLog快速使用 NLog配置 NLog通过代码定义配置 Target Layouts Layout Renderers

  4. [转]Using NLog for ASP.NET Core to write custom information to the database

    本文转自:https://github.com/NLog/NLog/issues/1366 In the previous versions of NLog it was easily possibl ...

  5. 关于NLog的target和Layout

    这个没啥好说的,都是用别人的东西,看文档就行了,写的很详细. https://github.com/NLog/NLog/wiki/Configuration-file https://github.c ...

  6. Nlog配置实例

      彩色Console target <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns= ...

  7. NLog在Asp.Net MVC的实战应用

    Asp.Net MVC FilterAttribute特性.读取xml反序列化.NLog实战系列文章 首先新建一个MVC project. 一.NLog的配置. 作者:Jarosław Kowalsk ...

  8. [转]C# 使用Nlog记录日志到数据库

    本文转自:http://www.cnblogs.com/weixing/archive/2013/04/26/3044422.html 摘要]Nlog是一个很不错的.NET日志记录组件,它可以将日志输 ...

  9. [转]ASP.NET Core 开发-Logging 使用NLog 写日志文件

    本文转自:http://www.cnblogs.com/Leo_wl/p/5561812.html ASP.NET Core 开发-Logging 使用NLog 写日志文件. NLog 可以适用于 . ...

随机推荐

  1. stegsolve的功能

  2. JAVA学习必须掌握的框架,不看后悔

    Web应用,最常见的研发语言是Java和PHP. 后端服务,最常见的研发语言是Java和C/C++. 大数据,最常见的研发语言是Java和Python. 可以说,Java是现阶段中国互联网公司中,覆盖 ...

  3. 简单的 socket 代码

    TCP 编程 客户端代码 将键盘输入的字符发送到服务端,并将从服务端接收到的字符输出到终端 #!/usr/python3 import socket def socket_client(): s = ...

  4. 题解 P1436 【棋盘分割】

    题目链接 其实呢大致思路和下面的大佬们都很像.发这篇题解的目的就是加了一点~~优化~~骗分技巧. 转移方程: 设$dp[i][j][x][y][k]$表示左上$(i,j)$,右下$(x,y)$,第$k ...

  5. 深度剖析MQTT协议的整个通信流程

    http://www.elecfans.com/d/587483.html MQTT,目前物联网的最主要的协议,基本所有收费的云平台都是基于MQTT协议,比如机智云,和所有的开放云平台比如中国移动的o ...

  6. ubtuntu 如何查看内存用量 mongostat详解

    free -h top free或者top或者cat /proc/meminfo mongostat是mongdb自带的状态检测工具,在命令行下使用.它会间隔固定时间获取mongodb的当前运行状态, ...

  7. c3中基本动画

    动画:是CSS3中具有颠覆性的特征之一,可通过设置多个节点来精确控制一个或一组动画,常用来实现复杂的动画效果:. 必要元素: a.通过@keyframes指定动画序列:自动补间动画,确定两个点,系统会 ...

  8. 了解一个名词——GTD

    概念:就是Getting Things Done的缩写,翻译过来就是“把事情做完”,是一个管理时间的方法. 核心理念概括:就是必须记录下来要做的事,然后整理安排并使自己一一去执行. 五个核心原则是:收 ...

  9. (Keil) Debug & Simulation 操作

    0x00 printf在MCU環境下print debug error message,利用Logic Analyzer模擬MCU register or GPIO狀態. 若是要要使用printf函數 ...

  10. 理解Javascript_02_执行上下文02

    上一篇我们讲到在全局环境下的代码段中,执行上下文环境中如何处理数据: 变量.函数表达式——变量声明,默认赋值为undefined: this——赋值: 函数声明——赋值: 这篇文章讲关于函数执行上下文 ...