Custom output templates

Prerequisites: install formatting module, use one of text-based logs (console or file).

Constructing custom templates

There are two ways to obtain a custom template:
  • Parse it from an arbitrary string:
    • var template = OutputTemplate.Parse("Here's the message: {Message}{NewLine}");
  • Use OutputTemplateBuilder to construct it in code:
    • var template = new OutputTemplateBuilder()
      .AddText("Here's the message: ")

Passing to a log instance

Custom output templates can be passed to text-based logs as parameters in their respective settings:
var log = new ConsoleLog(new ConsoleLogSettings
OutputTemplate = customTemplate
var log = new FileLog(new FileLogSettings
OutputTemplate = customTemplate