-
Notifications
You must be signed in to change notification settings - Fork 123
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
Customize filename while using rolling policies #243
Comments
I agree, some custom config to provide a name without date timestamp like 'log.txt' not 'log-220630.txt' |
any update? |
Any News? |
An 'update' and/or 'news' would require a) an agreed spec b) a PR implementing that
|
So it's not possible to let the rolling policy save the file in another folder than the original one? Because I really would need that to keep it organized. |
@ReikoTigon maybe this plugin would work for you: cocowalla/serilog-sinks-file-archive ? |
Hmm if i get the plugin correctly it moves them instead of deleting them? or be able to name the current log sth like "current.log" and all the old logs "log_DATE.log" like it would do atm. |
In NLog, there are some properties such as "archiveEvery" and "archiveDateFormat" that only modify archived files. Is it possible to customize the same for serilog-sinks-file? see: https://nlog-project.org/documentation/v3.2.1/html/Properties_T_NLog_Targets_FileTarget.htm |
Hi folks! Most of this sink's heavy lifting (formatting and so on) is implemented by Serilog ( It's fairly straightforward to wire these things up in a new sink that behaves in one of the ways suggested so far in this thread. Sinks are just simple classes that implement The hesitation to add more filename rolling styles and path formatting here is because although it's not a lot of code to construct a sink for one of these cases targeting one platform, the complexity of trying to support everything in the one sink is likely to turn it into a much heavier package than what we have today, and there's not a lot of enthusiasm for that among the Serilog maintainers as far as I can tell. If anyone's keen to implement their own specific case as a separate sink class, using formatters and so on from the packages mentioned above, and runs into trouble I'd be very happy to help - dropping a question on Stack Overflow tagged Unfortunately although it's nice to have a place to comment, this ticket is likely to be unproductive and noisy so I'll limit further activity to updates from maintainers. If anyone out there makes progress on either an implementation of a standalone sink with different rolling or formatting behavior, or a fork that adds more sophisticated configuration, we can post some links to their work here. |
If customizing filenames is a requirement, and you have the option of choosing your logging framework, you might consider taking a look at NLog, instead. |
There is also a fork of this Sink, |
Hi,
You can log an issue in my repo for more features and requests Would be happy to get your feedback: |
Hi,
Is there a possibility that this functionality will be added in the future? Can an implementation proposal be made? Thanks, and sorry for the many questions. |
Yes, environment strings are not expanded. Note there are multiple aspects here
The main point here is that any proposal needs to solve across all the needs - the impl will be the easy bit after reconciling how the rolling policy vs other factors are reconciled. The biggest elephant in the room is that the download numbers tell you this is an extremely widespread usage sink, so adding lots of fiddly config options is off the table - you're adding noise to basic config affecting a very large number of developers if a lot of options suddenly need to be considered (that does not make it undoable, it just makes it not a five minute job to formulate a good proposal) |
@pampua84 FWIW, switching to configuration in C# makes these kinds of things much easier: .WriteTo.File(
$"log-{Environment.GetEnvironmentVariable("MACHINENAME")}-.txt",
rollingInterval: RollingInterval.Day) |
@nblumhardt Yes I solved it this way, reading some ad hoc settings on the appsettings and not the standard ones of Serilog. Thanks |
…aceholder. This commit simply adds support to include date at the start (instead of the end) of filename whenever needed. Relevant Tests were also added For PathRoller.cs in TemplatedPathRollerTests.cs This commit partially addresses serilog#243
Requesting a out-of-the-box capability to customize a filename while using rolling policies.
The text was updated successfully, but these errors were encountered: