Add ability for static base file and customizable file roll patterns. #345
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In my work, a number of our projects use Serilog. One project has a task to revamp the logging to use items like Elastic/FluentD, but must also still output to a static file for developer/support engineer use in the field.
Given that a number of projects were using Serilog, this seemed an easier feature to add than to figure out other logging libraries/roll our own. Other sinks forked off of this removed the NETStandard 2.0 compatibility, which was a no-go for use on our end.
Did this in my own time both to help my work, but to have something I can use outside of work on my tinkering projects.
Adds 3 optional parameters:
bool
) - Keep the base file name passed in (log.txt
for instance) as the base file.Func<DateTime?,string>
) - Function to give a custom format for rolling files. The yyyyMMDD format did not work for requirements.string
) - A string regex pattern that will match the output of customFormatFunc. This must be provided when custom format is used, as the rollovers will not work (nor will it validate).