Layout Renderers

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.

时间: 2024-10-10 22:44:01

Layout Renderers的相关文章

C#开源日志Nlog入门

c#语言使用的日志比较多,比如:Log4.NLog等,今天我就简单随笔记录哈NLog的使用. 1.NLog的安装: 直接在VS编译器中打开程序包管理器,输入Install-Package NLogin添加进行自己的项目: VS程序包管理器请查看 http://blog.csdn.net/doris_d/article/details/46558351 2.安装NLog配置文件: 同上在程序包管理器中加入Install-Package NLogin.config: 3.添加完成之后,目录大致如下:

NLog学习笔记二:深入学习

配置文件 NLog所有的配置信息都可以写到一个单独的xml文件中,也可以在程序代码中进行配置. 配置文件位置 启动的时候,NLog会试图查找配置文件完成自动配置,查找的文件依次如下(找到配置信息则结束查询): 应用程序的标准配置文件(通常为applicationname.exe.config) 应用程序所在目录中的applicationname.exe.nlog文件 应用程序所在目录中的NLog.config文件 NLog.dll所在目录中的NLog.dll.nlog文件 环境变量NLOG_GL

NLog类库使用探索——详解配置

1 配置文件的位置(Configuration file locations) 通过在启动的时候对一些常用目录的扫描,NLog会尝试使用找到的配置信息进行自动的自我配置. 1.1 单独的*.exe客户端 单独的客户端,NLog将在以下目录搜索配置信息: 标准的程序配置文件(通常为 程序名.exe.config) 程序目录下的程序名.exe.nlog文件 程序目录下的NLog.config文件 NLog.dll所在目录下的NLog.dll.nlog文件 (在Nlog没有导入GAC情况下) 1.2

Nlog 配置总结

Writes log messages to one or more files. Since NLog 4.3 the ${basedir} isn't needed anymore for relative paths. Supported in .NET, Silverlight, Compact Framework and Mono. Configuration Syntax <targets> <target xsi:type="File" name=&qu

NLog文章系列——如何配置NLog(转)

NLog使用方法 作者:Jaros?aw Kowalski <> 翻译:CrazyCoder(由衷感谢他的热心!!) 原文:http://www.nlog-project.org/config.html 更多关于NLog的中文文章,请参考<NLog文章系列>. NLog支持以多种不同方式配置,目前同时支持直接编程和使用配置文件两种方法.本文将对目前支持的各种配置方式作详细描述. 日志配置 通过在启动的时候对一些常用目录的扫描,NLog会尝试使用找到的配置信息进行自动的自我配置.当你

NLog文章系列——如何配置NLog

NLog支持以多种不同方式配置,目前同时支持直接编程和使用配置文件两种方法.本文将对目前支持的各种配置方式作详细描述. 日志配置 通过在启动的时候对一些常用目录的扫描,NLog会尝试使用找到的配置信息进行自动的自我配置.当你运行一个独立的*.exe客户端可执行程序时,NLog将在以下目录搜索配置信息: 标准的程序配置文件(通常为 程序名.exe.config) 程序目录下的程序名.exe.nlog文件 程序目录下的NLog.config文件 NLog.dll所在目录下的NLog.dll.nlog

log4net 发布到生产环境不写日志的解决方法

1.升级到log4net的最新版 PM下执行 Install-Package log4net 还是无法解决的,使用下面的方法 2.使用Nlog替换之,详见https://github.com/NLog/NLog/wiki/Tutorial NLog使用方法比log4net更为简单,配置文件如下,如果成windows程序需将NLog.config自动复制到bin下面 1 <?xml version="1.0" encoding="utf-8" ?> 2 &

NLog日志记录

配置NLog NLog支持 .Net 4.5 以及以上版本! 首先去下载NLog的DLL下载地址:http://nlog-project.org/download/  然后把下载下来的Nlog.dll ,Nlog,extension.dll 加入项目reference. 之后就是配置NLog.config  格式如下: 通过在启动的时候对一些常用目录的扫描,NLog会尝试使用找到的配置信息进行自动的自我配置. 在ASP.NET项目中搜索的目录包括: 标准的web程序配置文件web.config

.Net Core 使用NLog记录日志到文件和数据库

NLog 记录日志是微软官方推荐使用. 接下来,通过配置日志记录到文件和Sql Server数据库. 第一步:首先添加包NLog.Config (可通过微软添加包命令Install-Package 包名进行添加,也可以通过管理NuGet程序包进行添加),添加成功后会生成NLog.config配置文件.并对该配置文件进行配置.详细配置可参考Git上 NLog说明. 一下是我个人配置. 1 <?xml version="1.0" encoding="utf-8"