Skip to content

[Improvements] Logger.cs — Log entry timestamps always local time regardless of rotation setting #499

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Info

File: src/Servy.Core/Logging/Logger.cs, line 304

Description:
Log entry timestamps always use DateTime.Now (local time):

$"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}]"

If useLocalTimeForRotation is false (UTC mode), log rotation uses UTC but log entries are stamped in local time. This mismatch means a rotation at midnight UTC appears to happen at a different time than the last logged entry before it, confusing log analysis.

Suggested fix:
Use DateTime.UtcNow when _useLocalTimeForRotation is false, consistent with the rotation logic.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions