NLog.StructuredEvents

Parsing and rendering of message templates. Fully backwards-compatible with Serilog's message template format and String.Format().
Getting started
Most of the time, you'll use NLog.StructuredEvents as an integrated part of NLog 4.5+. There's no additional API required for this: just pass a message template to ILogger.Info() and any other method that normally accepts a format string:
logger.Info("User {Username} logged in from {IPAddress}", username, ipAddress)
// -> An event with `Username` and `IPAddress` propertiesTo use NLog.StructuredEvents as a stand-alone parser or renderer, first install the NuGet package:
Install-Package NLog.StructuredEvents -PreParsing
The TemplateParser.Parse() method converts a message template string into a Template object:
var template = TemplateParser.Parse("User {Username} logged in from {IPAddress}");You can inspect the individual tokens in the template's Literals and Holes properties.
Rendering
To render a template, the values assigned to each Hole must be provided positionally:
template.Render(CultureInfo.CurrentCulture, "alice", "192.168.10.20");
// -> User "alice" logged in from "192.168.10.20" License
Dual licensed: MIT/BSD (choose one ;))

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
