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

Map ignores retainedFileCountLimit #29

Closed
markat1 opened this issue May 18, 2021 · 3 comments
Closed

Map ignores retainedFileCountLimit #29

markat1 opened this issue May 18, 2021 · 3 comments

Comments

@markat1
Copy link

markat1 commented May 18, 2021

Hi,
I have a problem regarding limiting the number of log files.

I have retainedFileCountLimit 2, but map seems to ignore this rule. Unfortunately it creates more than 2 files.

 .WriteTo.Async(a =>
            {
                a.Map<string>(
                    e => DateTime.Now.ToString("dd_MM_yyyy"),
                    (v, wt) => wt.File($"{AppDomain.CurrentDomain.BaseDirectory}/logs/log_{v}.txt",
                                       retainedFileCountLimit: 2,
                                       outputTemplate: "[{Timestamp:dd/MM/yyyy HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
                                       buffered: true,
                                       fileSizeLimitBytes: 105000000),
                    sinkMapCountLimit: 1);
            }, bufferSize: 120000)

it should only have been 2 files, but I see 3 files:

log_15_05_2021.txt
log_16_05_2021.txt
log_17_05_2021.txt
@overlego
Copy link

getting the same issue, anyone got a fix?

@bartelink
Copy link
Member

The Map Sink does not implement limiting/trimming - it just fans out over an unlimited number of sink configurations

The File Sink does implement trimming, but does not let you customize the naming strategy
It's way beyond the remit of Map to manage sinks over time (and Sinks would need to impleent some generic way to route requests to trim if it decided there were too many etc)

The bottom line here is that

  • The Map Sink does not (and can not) implement a retainedFileCountLimit
  • the File Sink implements a retainedFileCountLimit

Thus the most likely way to achieve your goal is to:

@bartelink bartelink closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2023
@bartelink
Copy link
Member

Duplicate of #15 (feature request to implement generic trimming)

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

No branches or pull requests

3 participants