Hi Mike. I want to have the appender defined in the configuration for doccumentation and because having log configuration external to the program is (at least) half the point of a logging system IMHO.
The problem with setting a threshold on the appender to cause it not ot log is that I don't see a way to programmatically set the threshold to a specific level. It can be bumped up or down, but that requires the program to know where the threshold was set in the configuration. I.E. configuration in the program, which I'm trying to avoid. The best I've been able to come up with is to define a logger with a threshold which won't log, call it deactivated, and assign this appender to it. Then to activate this appender, I can use appender_by_name(...) and get_root_logger()->add_appender(...). It took me a while to find it as get_root_logger is only defined on Log::Log4perl::Logger, not in Log::Log4perl. Thomas Erskine Consultant | Technology 2000 Barrington St | Suite 300 | Floor 04 Halifax, NS B3J3K1 Phone: +1 902 442-4709 [EMAIL PROTECTED] > -----Original Message----- > From: Mike Schilli [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 29, 2008 5:29 PM > To: Erskine, Thomas (IT) > Cc: log4perl-devel@lists.sourceforge.net > Subject: Re: [log4perl-devel] activating appenders > > On Wed, 29 Oct 2008, Erskine, Thomas (IT) wrote: > > > I want to be able to define an appender in the log4perl > config file, > > but not activated and then activate it programmatically However, > > Log::Log4perl->appender_by_name('SCREENDEBUG') returns undef. > > > > I guess I could add SCREENDEBUG to the log4perl.logger line > and define > > it with a threshold which won't log anything and then bump the > > threshold up at runtime, but it seems wrong somehow. > > An appender that's not assigned to any logger in the > configuration is ignored by Log4perl at this point -- I think > that using a threshold, as you've suggested, is a perfectly > valid solution, though. > > Alternatively, you can define the appender programmatically > and add it to the logger via add_appender(). > > -- Mike > > Mike Schilli > [EMAIL PROTECTED] > -------------------------------------------------------- NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel