Skip to content

Commit

Permalink
Merge pull request #18 from Kromi75/LogMessageTimestamp
Browse files Browse the repository at this point in the history
Use the timestamp of the original log event
  • Loading branch information
josephwoodward authored Jul 3, 2020
2 parents 2997661 + 590e3d4 commit 081598d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Serilog.Sinks.Loki/LokiBatchFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ public void Format(IEnumerable<LogEvent> logEvents, ITextFormatter formatter, Te
// We also remove backslashes and replace with forward slashes, Loki doesn't like those either
stream.Labels.Add(new LokiLabel(property.Key, property.Value.ToString().Replace("\"", "").Replace("\r\n", "\n").Replace("\\", "/")));

var localTime = DateTime.Now;
var localTimeAndOffset = new DateTimeOffset(localTime, TimeZoneInfo.Local.GetUtcOffset(localTime));
var time = localTimeAndOffset.ToString("o");
var time = logEvent.Timestamp.ToString("o");

var sb = new StringBuilder();
sb.AppendLine(logEvent.RenderMessage());
Expand Down

1 comment on commit 081598d

@PJB3005
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to update the NuGet package to include this change? Thanks!

Please sign in to comment.