This is an automated email from the ASF dual-hosted git repository. freeandnil pushed a commit to branch Fix_#231_Positive_CountDirection_roll in repository https://gitbox.apache.org/repos/asf/logging-log4net.git
commit 17ac3f753142d814ff6c3d5fa9c3eea8f07565f2 Author: gdziadkiewicz <[email protected]> AuthorDate: Tue Feb 25 19:12:02 2025 +0100 Add debug logging for file deletion and fix base name path handling in RollingFileAppender for positive CountDirection, extension preservation and logs in dir --- src/log4net/Appender/RollingFileAppender.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/log4net/Appender/RollingFileAppender.cs b/src/log4net/Appender/RollingFileAppender.cs index a91b7e27..6c70e92c 100644 --- a/src/log4net/Appender/RollingFileAppender.cs +++ b/src/log4net/Appender/RollingFileAppender.cs @@ -1171,8 +1171,11 @@ protected bool FileExists(string path) /// </remarks> protected void DeleteFile(string fileName) { + LogLog.Debug(_declaringType, $"Trying to delete [{fileName}]"); + if (!FileExists(fileName)) { + LogLog.Debug(_declaringType, $"[{fileName}] does not exist"); return; } // We may not have permission to delete the file, or the file may be locked @@ -1346,7 +1349,7 @@ protected virtual void RollOverRenameFiles(string baseFileName) if (PreserveLogFileNameExtension) { string extension = Path.GetExtension(archiveFileBaseName); - string baseName = Path.GetFileNameWithoutExtension(archiveFileBaseName); + string baseName = Path.Combine(Path.GetDirectoryName(archiveFileBaseName), Path.GetFileNameWithoutExtension(archiveFileBaseName)); int lastDotIndex = baseName.LastIndexOf(".", StringComparison.Ordinal); if (lastDotIndex >= 0) {
