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

NLog.Targets.MemoryTarget

Writes log messages to Logs in memory for programmatic retrieval.
public bool BlockingEnumeration { get; set; }

Gets or sets a value indicating whether enumeration of Logs blocks application logging. Blocking enumeration provides a consistent view of the logs, but can temporarily block application logging. When set to false, logging can continue during enumeration, but items can be skipped if the ring-buffer wraps while the enumeration is in progress.

public IList<string> Logs { get; }

Gets the list of logs gathered in the MemoryTarget.

public int MaxLogsCount { get; set; }

Gets or sets the maximum number of logs to retain in memory. Zero or Negative means no limit.

public MemoryTarget()

Initializes a new instance of the MemoryTarget class.

public MemoryTarget(string name)

Initializes a new instance of the MemoryTarget class.

public string DumpInitialError()

Dumps the first log message at Error or more severe, or the first log message containing an exception.

public string DumpOnError()

Dumps all captured log messages as a string if any log event with Error or more severe, or with an exception, have been logged.

public bool HasLogLevel(LogLevel minLevel)

Whether any log events with specified minLevel or more severe have been logged.