${cached} - Applies caching to another layout output.
${db-null} - Render DbNull for the database
${level} - The log level (e.g. ERROR, DEBUG) or level ordinal (number)
${literal} - A string literal. (text) - useful to escape brackets
${message} - The (formatted) log message.
${newline} - A newline literal.
${object-path} - Render a (nested) property of an object
Callsite and stacktraces
${callsite} - The call site (class name, method name and source information)
${callsite-filename} - The call site source file name.
${callsite-linenumber} - The call site source line number.
${stacktrace} - Render the Stack trace
Conditions
${when} - Only outputs the inner layout when the specified condition has been met.
${whenempty} - Outputs alternative layout when the inner layout produces empty result.
Context information
${activity} - Capture span context details like request TraceId from System.Diagnostics.Activity.Current package NLog.DiagnosticSource External
${activityid} - Puts into log a System.Diagnostics trace correlation id.
${all-event-properties} - Log all event context data.
${event-properties} - Log event properties data - rename of ${event-context} ${event-property}
${exception} - Exception information provided through a call to one of the Logger methods
${exceptiondata} - Lookup item in Exception.Data-Dictionary from Exception provided together with the LogEven
${gdc} - Global Diagnostic Context item. Dictionary structure to hold per-application-instance values.
${install-context} - Installation parameter (passed to InstallNLogConfig).
${logger} - The logger name. GetLogger, GetCurrentClassLogger etc ${loggername}
${mdc} - Mapped Diagnostics Context - a thread-local structure.
${mdlc} - Async Mapped Diagnostics Context - a thread-local structure for scoped context. Async version of the MDC.
${ndc} - Nested Diagnostics Context - a thread-local structure.
${ndlc} - Async Nested Diagnostics Context - thread-local structure.
${onexception} - Only outputs the inner layout when exception has been defined for log message.
${onhasproperties} - Only outputs the inner layout when event properties are included with the logevent.
${scopenested} - ScopeContext Nested states from the thread execution context (Ex. BeginScope). Similar to Nested Diagnostic Context (NDC) in Log4j
${scopeproperty} - ScopeContext Properties from the thread execution context (Ex. BeginScope). Similar to Mapped Diagnostic Context (MDC) in Log4j
${scopetiming} - ScopeContext Timing formats scope duration time (Ex. BeginScope).
${var} - NLog Logging Configuration Variable Value
Counters
${counter} - A counter value (increases on each layout rendering)
${guid} - Globally-unique identifier(GUID).
${sequenceid} - The log sequence id
Date and time
${date} - Current date and time.
${longdate} - The date and time in a long, sortable format yyyy-MM-dd HH:mm:ss.ffff
.
${shortdate} - The short date in a sortable format yyyy-MM-dd.
${ticks} - The Ticks value of current date and time.
${time} - The time in a 24-hour, sortable format HH:mm:ss.mmm.
Encoding and string transformations
${json-encode} - Escapes output of another layout using JSON rules.
${left} - Left part of a text
${lowercase} - Converts the result of another layout output to lower case.
${norawvalue} - Prevents the output of another layout renderer to be treated as raw value
${pad} - Applies padding to another layout output.
${replace} - Replaces a string in the output of another layout with another string. Optional with regex
${replace-newlines} - Replaces newline characters with another string.
${right} - Right part of a text
${rot13} - Decodes text "encrypted"with ROT-13.
${substring} - Substring of a text
${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.
${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.
Environment and config files
${appsetting} - App config setting from .config file
${configsetting} - Value from the appsettings.json or other configuration in ASP.NET Core & .NET Core package NLog.Extensions.Loggingpackage NLog.Extensions.Hostingpackage NLog.Web.AspNetCore
${environment} - The environment variable. (e.g PATH, OSVersion)
${registry} - A value from the Windows Registry. package NLog.WindowsRegistry
Files and directories
${basedir} - The current application domain’s base directory.
${currentdir} - The current working directory of the application.
${dir-separator} - The the OS dependent directory separator.
${file-contents} - Renders contents of the specified file.
${filesystem-normalize} - Filters characters not allowed in the file names by replacing them with safe character.
${nlogdir} - The directory where NLog.dll is located.
${processdir} - The executable process directory of the application.
${specialfolder} - System special folder path (includes My Documents, My Music, Program Files, Desktop, and more).
${tempdir} - A temporary directory.
Identity
${environment-user} - User identity information (username).
${identity} - Thread identity information (name and authentication information).
${windows-identity} - Thread Windows identity information (username) package NLog.WindowsIdentity
Integrations
${gelf} - Converts LogEvents into GELF format for sending to Graylog package NLog.GelfLayout External
${log4jxmlevent} - XML event description compatible with log4j, Chainsaw and NLogViewer.
${microsoftconsolelayout} - Write events to text format similar to Microsoft AddConsole Formatter for Microsoft.Hosting.Lifetime package NLog.Extensions.Loggingpackage NLog.Extensions.Hostingpackage NLog.Web.AspNetCore
Processes, threads and assemblies
${appdomain} - Current app domain.
${assembly-version} - The version of the executable in the default application domain.
${gc} - The information about the garbage collector.
${hostname} - The host name of the computer that the process is running on.
${local-ip} - Local IP Address from Network Interface.
${machinename} - The machine name that the process is running on.
${performancecounter} - The performance counter. package NLog.PerformanceCounter
${processid} - The identifier of the current process.
${processinfo} - The information about the running process. e.g. StartTime, PagedMemorySize
${processname} - The name of the current process.
${processtime} - The process lifetime in format HH:mm:ss.mmm.
${threadid} - The identifier of the current thread.
${threadname} - The name of the current thread.
Web, ASP.NET and ASP.NET Core
${aspnet-appbasepath} - ASP.NET Application base path (Content Root) package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-application} - ASP.NET Application variable. package NLog.Web
${aspnet-environment} - ASP.NET Environment name package NLog.Web.AspNetCore
${aspnet-httpcontext-item} - ASP.NET HttpContext
Items Dictionary Value. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-mvc-action} - ASP.NET MVC Action Name from routing parameters package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-mvc-controller} - ASP.NET MVC Controller Name from routing parameters package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request} - ASP.NET Request variable. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-bidirectional-stream} - ASP.NET Request capable of upgrading connection to an opaque, bidirectional stream. package NLog.Web.AspNetCore
${aspnet-request-client-certificate} - ASP.NET Request Client Certificate package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-connection-id} - ASP.NET Http Request Connection Id. The unique identifier that represents the connection. package NLog.Web.AspNetCore
${aspnet-request-contentlength} - ASP.NET Request Header Content-Length package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-contenttype} - ASP.NET Content-Type header (Ex. application/json) package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-cookie} - ASP.NET Request cookie content. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-duration} - ASP.NET Request Duration. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-endpoint} - ASP.NET Request EndPoint display name. package NLog.Web.AspNetCore
${aspnet-request-form} - ASP.NET Request form content. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-has-posted-body} - ASP.NET posted body / payload was included with the request package NLog.Web.AspNetCore
${aspnet-request-headers} - ASP.NET Header key/value pairs. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-host} - ASP.NET Request host. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-http-transport-type} - ASP.NET supported transport types that the client can use to send HTTP requests package NLog.Web.AspNetCore
${aspnet-request-inherent-keep-alive} - ASP.NET Request using connection transport capable of ‘inherent keep-alive’ package NLog.Web.AspNetCore
${aspnet-request-ip} - Client IP. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-local-ip} - ASP.NET Request HttpContext.Connection.LocalIpAddress package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-local-port} - ASP.NET Request HttpContext.Connection.LocalPort package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-method} - ASP.NET Request method (GET, POST etc). package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-posted-body} - ASP.NET posted body / payload package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-querystring} - ASP.NET Request querystring. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-referrer} - ASP.NET Request referrer. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-remote-port} - ASP.NET Request HttpContext.Connection.RemotePort package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-routeparameters} - ASP.NET Request route parameters. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-servervariable} - ASP.NET Server Variable (Ex. APP_POOL_ID) package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-stream-id} - ASP.NET Http Request Stream Id. The unique identifier that represents the reusable socket. package NLog.Web.AspNetCore
${aspnet-request-tls-handshake} - ASP.NET TLS Handshake Features ITlsHandshakeFeature of the connection. package NLog.Web.AspNetCore
${aspnet-request-tls-token-binding} - ASP.NET TLS Token Bindings for Provider and Referrer package NLog.Web.AspNetCore
${aspnet-request-tracking-consent} - ASP.NET Tracking Consent package NLog.Web.AspNetCore
${aspnet-request-trailers} - ASP.NET Request Trailers package NLog.Web.AspNetCore
${aspnet-request-url} - ASP.NET Request URL. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-useragent} - ASP.NET Request useragent. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-request-web-socket-requested-protocols} - ASP.NET Request HttpContext.WebSockets.WebSocketRequestedProtocols package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-response-contentlength} - ASP.NET Response status code content. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-response-contenttype} - ASP.NET Response Header Content-Type (Ex. application/json) package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-response-cookie} - Cookie Name and Values stored in the ASP.NET Response Cookies collection. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-response-has-started} - ASP.NET Http Response HasStarted package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-response-headers} - ASP.NET Response Headers key/value pairs. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-response-https-compression} - ASP.NET Response HTTPS Compression Mode package NLog.Web.AspNetCore
${aspnet-response-statuscode} - ASP.NET Response status code content. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-response-trailers} - ASP.NET Response Trailers package NLog.Web.AspNetCore
${aspnet-session} - ASP.NET Session variable. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-sessionid} - ASP.NET Session ID variable. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-traceidentifier} - ASP.NET trace identifier package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-user-authtype} - ASP.NET User auth. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-user-claim} - ASP.NET User Claims authorization values package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-user-identity} - ASP.NET User variable. package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-user-isauthenticated} - ASP.NET User authenticated? package NLog.Webpackage NLog.Web.AspNetCore
${aspnet-webrootpath} - ASP.NET Web root path (wwwroot) package NLog.Webpackage NLog.Web.AspNetCore
${iis-site-name} - IIS site name. package NLog.Webpackage NLog.Web.AspNetCore
来源:https://nlog-project.org/config/?tab=layout-renderers