<PackageReference Include="NLog" Version="6.2.2" />

NLog.Layouts.Layout

public abstract class Layout : ISupportsInitialize, IRenderable
Abstract interface that layouts must implement.
public static readonly Layout Empty

Default Layout-value that renders string.Empty

protected Layout()

public static Layout FromLiteral(string literalText)

Create a SimpleLayout containing literal value

public static Layout FromMethod(Func<LogEventInfo, object> layoutMethod, LayoutRenderOptions options = 0)

Create a SimpleLayout from a lambda method.

public static Layout FromString(string layoutText)

Parses the specified string as LayoutRenderer-expression into a SimpleLayout.

public static Layout FromString(string layoutText, ConfigurationItemFactory configurationItemFactory)

Parses the specified string as LayoutRenderer-expression into a SimpleLayout.

public static Layout FromString(string layoutText, bool throwConfigExceptions)

Parses the specified string as LayoutRenderer-expression into a SimpleLayout.

public static bool IsNullOrEmpty(Layout layout)

Indicates whether the specified layout is null or Empty.

public static Layout op_Implicit(string text)

Implicitly converts the specified string as LayoutRenderer-expression into a Layout.

public static void Register<T>(string name) where T : Layout

Obsolete and replaced by Setup with NLog v5.2. Register a custom Layout.

public static void Register(string name, Type layoutType)

Obsolete and replaced by Setup with NLog v5.2. Register a custom Layout.

protected virtual void CloseLayout()

Closes the layout.

protected abstract string GetFormattedMessage(LogEventInfo logEvent)

Renders formatted output using the log event as context.

protected virtual void InitializeLayout()

Initializes the layout.

public virtual void Precalculate(LogEventInfo logEvent)

Precalculates the layout for the specified log event and stores the result in per-log event cache. Skips context capture when Layout have [ThreadAgnostic], and only contains layouts with [ThreadAgnostic].

public string Render(LogEventInfo logEvent)

Renders formatted output using the log event as context.

public void Render(LogEventInfo logEvent, StringBuilder target)

Optimized version of Render that works best when override of RenderFormattedMessage is available.

protected virtual void RenderFormattedMessage(LogEventInfo logEvent, StringBuilder target)

Renders formatted output using the log event as context.

protected T ResolveService<T>()

Resolve from DI ServiceRepository