Skip to content

Instantly share code, notes, and snippets.

@jhollingworth
Created January 2, 2011 23:40
Show Gist options
  • Select an option

  • Save jhollingworth/762934 to your computer and use it in GitHub Desktop.

Select an option

Save jhollingworth/762934 to your computer and use it in GitHub Desktop.
class FileCleanerAppender : RollingFileAppender
{
public FileCleanerAppender()
{
File = "Foo.log";
AppendToFile = false;
RollingStyle = RollingMode.Once;
LockingModel = new MinimalLock();
Name = "SomeAppender";
Layout = new PatternLayout { ConversionPattern = "%m" };
ActivateOptions();
}
}
var logger = ((log4net.Repository.Hierarchy.Logger)LogManager.GetLogger("SomeLogger").Logger);
logger.AddAppender(new FileCleanerAppender());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment