ChangemakerStudios / serilog-sinks-mongodb

A sink for Serilog that writes events to MongoDB
Apache License 2.0
92 stars 53 forks source link

Serilog timestamp local time. #47

Closed sinanbozkus closed 2 years ago

sinanbozkus commented 5 years ago

I'm using Serilog MongoDb Sink with ASP.NET Core 2.2. But I have a big problem. All my records are like that. Timestamps values and UtcTimesamps values are always the same. I couldn't find any solution to fix it. I want to use the localtime for timestamp. How can I do that?

"_id" : "5d1a6815e688ed7b7833d870" "Timestamp": 2019-07-01T20:07:49.285+00:00 "Level": "Information" "MessageTemplate": "Test" "RenderedMessage": "Hello" "Properties": ... "UtcTimestamp": 2019-07-01 20:07:49Z

Tora-Bora commented 4 years ago

Hey, I have the same problem, both Timestamp and UtcTimestamp has the same value:

{ "_id" : ObjectId("5e254cc1d8b4963a0c155ae1"), "Timestamp" : ISODate("2020-01-20T06:46:25.667+0000"), "Level" : "Information", "MessageTemplate" : "Hello, world!", "RenderedMessage" : "Hello, world!", "UtcTimestamp" : "2020-01-20 06:46:25Z" }

Jaben commented 3 years ago

Please try with the latest version (v5.0.0) using the MongoDBBson sink:

Timestamp should now be correct:

image

LiderWebCroydon commented 2 years ago

image The time it takes in Timestamp is UTC, which is hard to keep track of. There is a way to take the local time for the log trace, check the time configuration in the container and it is correct