Log in | Jump |

jhollingworth

a blog about my life (twitter.com/jhollingworth)
This thing was constructed on February 23, 2010, and it was categorized as Uncategorized.
You can follow comments through the RSS 2.0 feed. You can leave a comment, or trackback.

I needed to programamatically add a log4net appender at runtime, the docs for all of this are all a little fuzzy so just for future reference


class FileCleanerAppender : RollingFileAppender

{

public FileCleanerAppender()

{

File = "Foo.log";

AppendToFile = false;

RollingStyle = RollingMode.Once;

LockingModel = new MinimalLock();

Name = "SomeAppender";

Layout = new PatternLayout { ConversionPattern = "%m" };

ActivateOptions();

}

}

((log4net.Repository.Hierarchy.Logger)LogManager.GetLogger("SomeLogger").Logger)

.AddAppender(new FileCleanerAppender());
This thing was constructed by .


You can follow comments through the RSS 2.0 feed. You can leave a comment, or trackback.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*