-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rolling file UTC support #56
Comments
Thanks for the suggestion, and sorry about the slow reply. Doing this seems entirely reasonable, but it's on the borderline of being too much of an edge case for us to want to add a setting for it. Forking the sink (it's a very small codebase) could be a decent option at this point - I'll close this issue as I don't think we'll make the change in the near future, but if enough people need the same thing and stumble across this ticket, we can definitely reevaluate. Cheers! |
Hello, |
Hi, I would also be interested to have such feature out of the box. |
Let's give this some more thought 👍 I don't think we'd open up the static hook point as-is (it's only there to facilitate testing); it'd be nicer to get rid of it and integrate through a public The case against this is the proliferation of arguments to |
Hi, How about next to the |
It actually doesn't appear to be such a rare scenario and I'm wondering why this issue is still not solved after five years?! Anyway, meanwhile we use this HACK as a workaround: var fileSinkTypes = typeof(Serilog.Sinks.File.FileSink).Assembly.GetTypes();
var clockType = fileSinkTypes.FirstOrDefault(x => string.Equals(x.FullName, "Serilog.Sinks.File.Clock", StringComparison.Ordinal));
var timestampProviderField = clockType?.GetField("_dateTimeNow", BindingFlags.Static | BindingFlags.NonPublic);
timestampProviderField?.SetValue(null, new Func<DateTime>(() => DateTime.UtcNow)); |
@6bee many other more interesting things got done instead - time and attention is finite unfortunately :-) serilog/serilog#1920 might evolve into a general solution to this, time providers can select their local time zone, which in this case could be set to UTC. |
Hi.
I want to configure serilog-sinks-file to create new log file each day according to UTC.
Please, take a look at your class Clock.cs:
https://github.com/serilog/serilog-sinks-file/blob/dev/src/Serilog.Sinks.File/Sinks/File/Clock.cs
Here you're using DateTime.Now, but what about using DateTime.UtcNow?
Is there any way to configure it to use UTC? Otherwise can you please add this feature?
The text was updated successfully, but these errors were encountered: