<PackageReference Include="Serilog" Version="4.3.2-dev-02419" />

Serilog.Events.LogEvent

public class LogEvent
A log event.
public Exception Exception { get; }

An exception associated with the event, or null.

public LogEventLevel Level { get; }

The level of the event.

The message template describing the event.

Properties associated with the event, including those presented in MessageTemplate.

public ActivitySpanId? SpanId { get; }

The id of the span that was active when the event was created, if any.

public DateTimeOffset Timestamp { get; }

The time at which the event occurred.

public ActivityTraceId? TraceId { get; }

The id of the trace that was active when the event was created, if any.

public LogEvent(DateTimeOffset timestamp, LogEventLevel level, Exception exception, MessageTemplate messageTemplate, IEnumerable<LogEventProperty> properties)

Construct a new LogEvent.

public LogEvent(DateTimeOffset timestamp, LogEventLevel level, Exception exception, MessageTemplate messageTemplate, IEnumerable<LogEventProperty> properties, ActivityTraceId traceId, ActivitySpanId spanId)

Construct a new LogEvent.

public static LogEvent UnstableAssembleFromParts(DateTimeOffset timestamp, LogEventLevel level, Exception exception, MessageTemplate messageTemplate, Dictionary<string, LogEventPropertyValue> properties, ActivityTraceId traceId, ActivitySpanId spanId)

Construct a LogEvent using pre-allocated values for internal fields. Normally, the LogEvent constructor allocates a dictionary to back Properties, so that this is not unexpectedly shared. This is unnecessary in many integration scenarios, leading to an additional nontrivial Dictionary<T, U> allocation. This method allows specialized callers to avoid that overhead.

public void AddOrUpdateProperty(LogEventProperty property)

Add a property to the event if not already present, otherwise, update its value.

public void AddPropertyIfAbsent(LogEventProperty property)

Add a property to the event if not already present.

public void AddPropertyIfAbsent(ILogEventPropertyFactory factory, string name, object value, bool destructureObjects = false)

Add a property to the event if not already present.

public void RemovePropertyIfPresent(string propertyName)

Remove a property from the event, if present. Otherwise no action is performed.

public void RenderMessage(TextWriter output, IFormatProvider formatProvider = null)

Render the message template to the specified output, given the properties associated with the event.

public string RenderMessage(IFormatProvider formatProvider = null)

Render the message template given the properties associated with the event, and return the result.