using log4net;
using log4net.Config;
using System.Reflection;
var pathConfig = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config.xml");
XmlConfigurator.Configure(new FileInfo(pathConfig));
var assembly = Assembly.GetEntryAssembly();
var logger = LogManager.GetLogger(assembly, "log");
logger.Info("Hello, log4net!");
When only 2024-08-02.0.log exists, it appends a new log to 2024-08-02.0.log as expected.
When both 2024-08-02.0.log and 2024-08-02.1.log exist and 2024-08-02.0.log is greater than 5MB, this code overwrites 2024-08-02.1.log and outputs the following error message:
log4net:ERROR RollingFileAppender: INTERNAL ERROR. Append is False but OutputFile [...\Log\2024-08-02.1.log] already exists.
It seems AppendToFile flag is ignored.
All log4net versions from 2.0.10 to 2.0.17 reproduce this issue.
When RollingStyle is Composite, it seems RollingFileAppender ignores AppendToFile flag except for the first log on that day.
The following code makes log files as 2024-08-02.0.log, 2024-08-02.1.log, ...
log4net.config.xml
Program.cs
When only 2024-08-02.0.log exists, it appends a new log to 2024-08-02.0.log as expected. When both 2024-08-02.0.log and 2024-08-02.1.log exist and 2024-08-02.0.log is greater than 5MB, this code overwrites 2024-08-02.1.log and outputs the following error message:
It seems AppendToFile flag is ignored.
All log4net versions from 2.0.10 to 2.0.17 reproduce this issue.