Event Context Layout Renderer

Rolf Kristensen edited this page Mar 21, 2017 · 4 revisions
Clone this wiki locally

Log event property data.

Supported in .NET, Silverlight, Compact Framework and Mono.

Configuration Syntax


Note that this syntax replaces the deprecated ${event-context} syntax.


Rendering Options

  • item - Name of the item (required)


In your C# code, create an event and add an element to the Properties dictionary (or the deprecated Context dictionary):

Logger log = LogManager.GetCurrentClassLogger();
LogEventInfo theEvent = new LogEventInfo(LogLevel.Debug, "", "Pass my custom value");
theEvent.Properties["MyValue"] = "My custom string";
// deprecated
theEvent.Context["TheAnswer"] = 42;

And in your NLog.config file:

${event-properties:item=MyValue}   -- renders "My custom string"
${event-properties:item=TheAnswer} -- renders "42"