-
Notifications
You must be signed in to change notification settings - Fork 11
Description
I know the preamble says to log sink specific stuff in the sink repo, however, I've checked the code for the trace sink and cannot find any sink specific date handling code.
Does this issue relate to a new feature or an existing bug?
- Bug
- New Feature
What version of Serilog is affected? Please list the related NuGet package.
Serilog 2.9.0
Serilog.Sinks.Trace 2.1.0
What is the target framework and operating system? See target frameworks & net standard matrix.
- .NET Core 3.1
- netCore 2.0
- netCore 1.0
- 4.7
- 4.6.x
- 4.5.x
Please describe the current behaviour?
The trace sink logs date/time in US format (which is not good, because that's not where I am):-
2020-04-02 09:37:54.463 +11:00 [Debug] timestamp: 04/02/2020 00:05:00
2020-04-02 10:27:49.677 +11:00 [Debug] "en-AU"
Also, notice the inconsistency... the entry date/time is in some custom format, yet DateTimes in output default to ? (I couldn't find the corresponding standard date/time format string).
Debug.WriteLine gets it right:-
timestamp: 2/04/2020 12:05:00 AM
As does the file sink (sort of. better, but not consistent):-
2020-04-02 09:37:54.463 +11:00 [DBG] timestamp: "2020-04-02T00:05:00.0000000+11:00"
Please describe the expected behaviour?
Use CurrentCulture instead of assuming I'm in the US.
2020-04-02 09:37:54.463 +11:00 [Debug] timestamp: 02/04/2020 00:05:00
Or at least keep the defaults consistent...
2020-04-02 09:37:54.463 +11:00 [Debug] timestamp: 2020-04-02 00:05:00.000 +11:00
If the current behaviour is a bug, please provide the steps to reproduce the issue and if possible a minimal demo of the problem
.WriteTo.Trace()
log.Debug("timestamp: {0}", ts);
log.Debug("{0}", System.Globalization.CultureInfo.CurrentCulture);
I notice this is marked as fixed in serilog/serilog#146 but doesn't seem to apply to the trace sink.
I see at https://github.com/serilog/serilog/wiki/Formatting-Output that I can work around the issue (I think, haven't tried it yet), but shouldn't these all be consistent and use CurrentCulture by default?
Instead of using InvariantCulture everywhere, could it keep a CultureInfo variable somewhere (default to InvariantCulture if it has to) and let us override in the setup?
It may seem trivial, but can be really annoying when you're working with dates in the first 12 days of the month or adding the same workaround code in every project just for trace.