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

NLog.LogEventBuilder

public struct LogEventBuilder
A fluent builder for logging events to NLog.
public LogEventInfo LogEvent { get; }

Logging event that will be written

public ILogger Logger { get; }

The logger to write the log event to

public LogEventBuilder(ILogger logger)

Initializes a new instance of the LogEventBuilder class.

public LogEventBuilder(ILogger logger, LogLevel logLevel)

Initializes a new instance of the LogEventBuilder class.

public LogEventBuilder Callsite(string callerClassName = null, string callerMemberName = null, string callerFilePath = null, int callerLineNumber = 0)

Writes the log event to the underlying logger.

Sets the exception information of the logging event.

public void Log(LogLevel logLevel = null, string callerMemberName = null, string callerFilePath = null, int callerLineNumber = 0)

Writes the log event to the underlying logger.

public void Log(Type wrapperType)

Writes the log event to the underlying logger.

public LogEventBuilder Message(string message)

Sets the log message on the logging event.

public LogEventBuilder Message<TArgument>(string message, TArgument argument)

Sets the log message and parameters for formatting for the logging event.

public LogEventBuilder Message<TArgument1, TArgument2>(string message, TArgument1 argument1, TArgument2 argument2)

Sets the log message and parameters for formatting on the logging event.

public LogEventBuilder Message<TArgument1, TArgument2, TArgument3>(string message, TArgument1 argument1, TArgument2 argument2, TArgument3 argument3)

Sets the log message and parameters for formatting on the logging event.

public LogEventBuilder Message(string message, object[] args)

Sets the log message and parameters for formatting on the logging event.

public LogEventBuilder Message(string message, ReadOnlySpan<object> args)

Sets the log message and parameters for formatting on the logging event.

public LogEventBuilder Message(IFormatProvider formatProvider, string message, object[] args)

Sets the log message and parameters for formatting on the logging event.

public LogEventBuilder Properties(IEnumerable<KeyValuePair<string, object>> properties)

Sets multiple per-event context properties on the logging event.

public LogEventBuilder Properties(IReadOnlyCollection<KeyValuePair<string, object>> properties)

Sets multiple per-event context properties on the logging event.

public LogEventBuilder Properties(ReadOnlySpan<ValueTuple<string, object>> properties)

Sets multiple per-event context properties on the logging event.

public LogEventBuilder Property<T>(string propertyName, T propertyValue)

Sets a per-event context property on the logging event.

Sets the timestamp of the logging event.