RE: Programmatically setting the logger level
"Kevin Wittmer" <[email protected]> Tue, 20 Jan 2004 08:03:39 -0600
| Newsgroups | gmane.comp.windows.dotnet.log4net.user |
|---|---|
| Message-ID | <[email protected]> |
[Setting the logger level programmatically] Thank you for the reply. Unfortunately, the following code fragment is not possible with version 1.1.1. fileAppender.Threshold = log4net.LogManager.GetLoggerRepository().LevelMap["WARN"]; The method GetLoggerRepository is not available in this implementation. LoggerWarning is implemented as a field/property, but I see no LevelMap Hashtable. There is a RenderedMap field/property, but I don't believe that is the same thing. [* Next release of log4net? *] It's possible that the 1.1.1 implementation is now quite dated. That begs the question: Is there a planned release of log4net any time soon? How could readers of this list help in moving up the release date? Is there additional testing that we could divided up among ourselves to validate a final release build? Kevin, >From: Nicko Cadell <[email protected]> >To: "'Kevin Wittmer'" <[email protected]>, >[email protected] >Subject: RE: [Log4net-users] Programmatically setting the logger level >Date: Mon, 19 Jan 2004 14:32:20 -0000 > >Kevin, > >Only the BufferingAppenderSkeleton classes support the Evaluator (i.e. the >ADONetAppender, BufferingForwardingAppender, RemotingAppender, SMTPAppender >and SmtpPickupDirAppender appenders). > >If what you want is to set the event threshold for the appender then you do >not need to use the Evaluator at all. i.e. the following configuration >would >work: > ><appender> > <param name="Threshold" value="WARN" /> ></appender> > >Or the equivalent: > ><appender> > <threshold value="WARN" /> ></appender> > >To set this in code you would use: > >fileAppender.Threshold = >log4net.LogManager.GetLoggerRepository().LevelMap["WARN"]; > >Hope this helps, > >Nicko > > > -----Original Message----- > > From: Kevin Wittmer [mailto:[email protected]] > > Sent: 16 January 2004 23:56 > > To: [email protected] > > Subject: [Log4net-users] Programmatically setting the logger level > > > > > > > > Hello, > > > > I am hoping that someone can rattle off a couple of lines of > > code that would > > show me how to programmatically set the logger level. > > > > If I want to accomplish the following: > > > > <appender> > > <evaluator type="log4net.spi.LevelEvaluator"> > > <param name="Threshold" value="WARN"/> > > </evaluator> > > </appender> > > > > In C# using the various log4net interface and classes, etc. > > How can this be > > done? > > > > My application currently includes the following: > > > > log4net.Appender.RollingFileAppender fileAppender = > > new log4net.Appender.RollingFileAppender( > > new log4net.Layout.PatternLayout( > > "%d [%t] %-5p %c - %m%n"), log4netFile); > > fileAppender.MaxFileSize = 65536; > > fileAppender.MaxSizeRollBackups = 3; > > log4net.Config.BasicConfigurator.Configure(fileAppender); > > > > Thanks! Maybe we could use the reply(s) from this posting to > > update the > > log4net documentation to include such an example. Or, maybe > > the solution to > > this could make its way into the log4net FAQ. > > > > Kevin > > > > _________________________________________________________________ > > Get a FREE online virus check for your PC here, from McAfee. > > http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 > > > > > > > > ------------------------------------------------------- > > The SF.Net email is sponsored by EclipseCon 2004 > > Premiere Conference on Open Tools Development and Integration > > See the breadth of Eclipse activity. February 3-5 in Anaheim, > > CA. http://www.eclipsecon.org/osdn > > _______________________________________________ > > Log4net-users mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/log4net-users > > _________________________________________________________________ Find high-speed net deals comparison-shop your local providers here. https://broadband.msn.com ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn