Currently when I use {Timestamp}
in an outputTemplate it appears to have been generated by DateTime.Now
and therefore being of DateTimeKind.L
It appears the limitation in DateTimeOffset
formatting is going to thwart this.
An alternative (so long as the additional property doesn't bloat output somewhere else) is to add a Serilog ILogEventEnricher
to the pipeline:
class UtcTimestampEnricher : ILogEventEnricher {
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory lepf) {
logEvent.AddPropertyIfAbsent(
lepf.CreateProperty("UtcTimestamp", logEvent.Timestamp.UtcDateTime));
}
}
You can then use {UtcTimestamp:o}
in your output template to get the value you need.