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

Add option to specify wildcard in DetermineLastFileLogName() #54

Open
dowdybrown opened this issue May 3, 2023 · 1 comment
Open

Add option to specify wildcard in DetermineLastFileLogName() #54

dowdybrown opened this issue May 3, 2023 · 1 comment
Labels

Comments

@dowdybrown
Copy link

dowdybrown commented May 3, 2023

Could an option be added to specify the wildcard used by DetermineLastFileLogName()? Line 166 of FileLoggerProvider.cs has a hard-coded "*". In my use case, I have MaxRollingFiles set to 3. So the log files should be basename, basename1 and basename2. The wildcard on line 166 would best be a "?" in my case. The problem with "*" is that there may be other log files that have been saved off for later investigation in the folder that "*" picks up, but "?" would filter out. As it is now, the code overwrites those log files that we had saved for later investigation. Work-around is to add a prefix to the filename, change the extension, or move them to a different folder.

@VitaliyMF
Copy link
Contributor

Regarding

Line 166 of FileLoggerProvider.cs has a hard-coded "*". In my use case, I have MaxRollingFiles set to 3. So the log files should be basename, basename1 and basename2. The wildcard on line 166 would best be a "?" in my case.

This code finds 'the latest' log file name for case when 'FileSizeLimitBytes' is set and log file name is not the only log file. It is assumed that the directory contains only log files generated by FileLoggerProvider, and ? is not suitable here because MaxRollingFiles can be 2-digit, 3-digit etc.

If this is not true in your case, I may recommend to use FormatLogFileName handler to generate custom log file names and/or control its folder. Note that FormatLogFileName is called often (each time when FileLoggerProvider is about to flush log messages to a file) and if code here adds a significant overhead the result should be cached somehow (this is up to you and totally depends on the logic inside FormatLogFileName handler).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants