logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mauro Rallo <ra...@prosa.com>
Subject Configure Log4net from code at RunTime
Date Tue, 23 Aug 2005 15:40:57 GMT
Hi, I need to add a child to the root category of logging at runtime.
I configure log4net at the startup of my application with the app.config file.
After I need to add some category with differents appenders.

I tried with this code, but it doesn't work :

Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
Logger rootLogger = hierarchy.Root;
Logger coreLogger = hierarchy.LoggerFactory.CreateLogger("abc");
RollingFileAppender roller = new RollingFileAppender();
PatternLayout patternLayout = new PatternLayout();
patternLayout.ConversionPattern = LogPattern;
roller.Layout = patternLayout;
roller.AppendToFile = true;
roller.RollingStyle = RollingFileAppender.RollingMode.Size;
roller.MaxSizeRollBackups = 4;
roller.MaximumFileSize = "100KB";
roller.StaticLogFileName = true;
roller.File = "foobar.txt";

log4net.ILog log3 =LogManager.GetLogger("abc");
log3.Debug("This message has to go to the foobar.txt File");

In the documentation of the Hierarchy class is write that "the hierarchy is such
that children link to their parent but parents do not have any references to
their children." 
But how I can say to the System that I added a new child?

It's possible to make it?
Someone can help me?

Thanks a lot


View raw message