serilog-archive / serilog-sinks-loggly

A Serilog event sink that writes to Loggly
Apache License 2.0
27 stars 30 forks source link

Bug fix: Retain Serilog event timestamp rather than time sent to Loggly #4

Closed mattc-lh closed 8 years ago

mattc-lh commented 8 years ago

Issue Events sent to Loggly via this sink have incorrect timestamps within Loggly - the time they (actually their whole batch) were sent to Loggly, rather than the time they were actually logged. With large batches or event queues, this can be quite a problematic data loss.

Cause Currently, the Serilog=>Loggly event translation drops the event's actual timestamp by omission - the Loggly event keeps its constructor-default of DateTimeOffset.UtcNow. Since the translation isn't done until a batch is ready to send, this effectively re-timestamps events (actually whole batches of events) with their sending time.

Fix The fix is trivial - explicitly set the Loggly event timestamp, using the Serilog event timestamp.

mivano commented 8 years ago

Nice catch, thanks!