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. 2018年第九届蓝桥杯C/C++A组省赛(最后一题)

    第十题 付账问题   [题目描述]    几个人一起出去吃饭是常有的事.但在结帐的时候,常常会出现一些争执.    现在有 n 个人出去吃饭,他们总共消费了 S 元.其中第 i 个人带了 ai 元.幸 ...

  2. RDD与DataFrame

    RDD:分布式对象集合: 解决了:减少中间计算结果处理所需的开销   数据存在内存,提供一个通用的抽象的数据结构 惰性求值 DataFrame:分布式Row对象集合 服务于:SparkSQL

  3. 用python实现按权重对N个数据进行选择

    需求:某公司有N个人,根据每个人的贡献不同,按贡献值给每个人赋予一个权重.设计一种算法实现公平的抽奖. 需求分析:按照权重对数据进行选择. 代码实现: 1 def fun(n,p): 2 " ...

  4. 【guava】对象处理

    一,equals方法 我们在开发中经常会需要比较两个对象是否相等,这时候我们需要考虑比较的两个对象是否为null,然后再调用equals方法来比较是否相等,google guava库的com.goog ...

  5. 【智能算法】用模拟退火(SA, Simulated Annealing)算法解决旅行商问题 (TSP, Traveling Salesman Problem)

    喜欢的话可以扫码关注我们的公众号哦,更多精彩尽在微信公众号[程序猿声] 文章声明 此文章部分资料和代码整合自网上,来源太多已经无法查明出处,如侵犯您的权利,请联系我删除. 01 什么是旅行商问题(TS ...

  6. Xamarin Forms:小马过河,王者归来

    因为我媳妇的原因,去年下半年从零开始学习Android原生开发,做了一个答题库app.整体给我的感觉是入门难度不大,前期折腾一番,大部分时间都是花在开发上面,其实任何一门语言都是如此. 今年我又有另一 ...

  7. PHP常用人工智能库

    1.NLPTools(http://php-nlp-tools.com/)NLPTools是一个PHP自然语言处理库.能进行文本分级,聚类等操作.2.Prediction Builder(https: ...

  8. 12.谈谈this对象的理解

    1.谈谈this对象的理解? 2.this指向问题   Javascript理解this对象 this是函数运行时自动生成的一个内部对象,只能在函数内部使用,但总指向调用它的对象. 通过以下几个例子加 ...

  9. origin横纵坐标颠倒

    origin默认是只能多个纵坐标,不能多个横坐标,所以这种情况只能先作成多个Y,然后像这样exchange一下.

  10. SPOJ - FAVDICE 简单期望

    dp[0]=0; // rep(i,1,n) dp[i]=(double)(n-i)/n*dp[i-1]+1+(double)(i)/n*dp[i]; // (n-i)/n dp[i]= n-i / ...