Skip to content
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

Wrong file retention with multiple logs in the same dir #22

Open
sommcz opened this issue Nov 24, 2024 · 0 comments · May be fixed by #23
Open

Wrong file retention with multiple logs in the same dir #22

sommcz opened this issue Nov 24, 2024 · 0 comments · May be fixed by #23

Comments

@sommcz
Copy link

sommcz commented Nov 24, 2024

I have configuration with two log files (debug and brief). I have configured archiveHook with different parameters for each one (300days and 1000days). They are written to the same directory.

"WriteTo": {
    "MainFile": {
        "Name": "File",
        "Args": {
            "path": "./Logs/log-debug.log",
            "rollingInterval": "Day",
            "retainedFileCountLimit": 7,
            "hooks": "My.Core.SerilogHooks::CompressArchive300Hook",
        }
    },
    "BriefFile": {
        "Name": "File",
        "Args": {
            "path": "./Logs/log-brief.log",
            "rollingInterval": "Day",
            "retainedFileCountLimit": 7,
            "hooks": "My.Core.SerilogHooks::CompressArchive1000Hook",
            "restrictedToMinimumLevel": "Information",
        }
    }
}
public static class SerilogHooks
{
	public static ArchiveHooks CompressArchiveHook => new ArchiveHooks(1000, CompressionLevel.Optimal);
	public static ArchiveHooks CompressArchive300Hook => new ArchiveHooks(300, CompressionLevel.Optimal);
        //....
}

Expected:
ArchiveHook deletes files in each group (by name pattern) based on theirs hook settings (number of retainedFiles)

Actual:
ArchiveHook deletes all files in log directory, so all files from one log (which is first in name sort) are deleted.

@sommcz sommcz changed the title Wrong file retention with multiple logs in one dir Wrong file retention with multiple logs in the same dir Nov 24, 2024
sommcz added a commit to sommcz/serilog-sinks-file-archive that referenced this issue Nov 25, 2024
sommcz added a commit to sommcz/serilog-sinks-file-archive that referenced this issue Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant