Skip to content

RollingFileAppender does not respect the MaxSizeRollBackups with positive CountDirection #231

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

Open
1 task done
gdziadkiewicz opened this issue Feb 25, 2025 · 0 comments · May be fixed by #232
Open
1 task done

Comments

@gdziadkiewicz
Copy link
Contributor

gdziadkiewicz commented Feb 25, 2025

TODO

  • Check if the problem is present for other RollingModes

config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<log4net>
		<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
			<param name="File" value=".\Log\optionalprefix.log" />
			<param name="AppendToFile" value="true" />
			<param name="RollingStyle" value="Composite" />
			<param name="DatePattern" value='yyyy-MM-dd-mm' />
			<param name="MaximumFileSize" value="1MB" />
			<param name="MaxSizeRollBackups" value="3" />
			<param name="StaticLogFileName" value="false" />
			<param name="CountDirection" value="1" />
			<param name="PreserveLogFileNameExtension" value="true"/>
			<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
			<layout type="log4net.Layout.PatternLayout">
				<param name="ConversionPattern" value="%d{yyyy/MM/dd HH:mm:ss.fff} [%-5p] %m (%M)%n"/>
			</layout>
		</appender>

		<logger name="log">
			<level value="debug" />
			<appender-ref ref="LogFileAppender" />
		</logger>
	</log4net>
</configuration>

program.cs

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");


for(int i = 0; i <10000000; ++i)
{
  logger.Info($"Hello, log4net! {i}");
}
@gdziadkiewicz gdziadkiewicz changed the title RollingFileAppender does not respect the MaxSizeRollBackups in Composite RollingMode with positive CountDirection RollingFileAppender does not respect the MaxSizeRollBackups with positive CountDirection Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant