[logback-user] Programmatically adding appenders

Jason Corbett jasoncorbett at gmail.com
Fri Mar 4 16:59:15 CET 2011


Ok, now I'm embarrassed.  Thank you.  Guess I shouldn't code when I'm that
tired.

Jason

On Thu, Mar 3, 2011 at 7:56 PM, Bee-lindgren, Bert A <
bert.bee-lindgren at oit.gatech.edu> wrote:

> Are you start( )'ing the appender?
>
> ------------------------------
> *From: *"Jason Corbett" <jasoncorbett at gmail.com>
> *To: *logback-user at qos.ch
> *Sent: *Thursday, March 3, 2011 7:46:29 PM
> *Subject: *[logback-user] Programmatically adding appenders
>
>
> I have searched, but have been unable to find a way to do this.  I need to
> add an appender after configuration has happened.  This is because whether
> or not the appender is even wanted is dependent on a runtime condition.
>  I've seen plenty of examples using the sifting appender, but I don't want
> to include the appender in the config file because I don't want to create a
> dependency on the appender being there (it's an optional component).
>
> I've tried this:
> LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
> Logger testcase_logger = lc.getLogger("test");
>  logAppender.setContext(testcase_logger.getLoggerContext());
> testcase_logger.addAppender(logAppender);
>
> But I never get any logging events (this is a custom log appender).  Test
> is the base of all the loggers I want logging to this appender (I want
> anything with a test. at the beginning of the logger name to write to this
> appender).
>
> Any ideas?
>
> My custom appender extends AppenderBase<ILoggingEvent>.
>
> Jason Corbett
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/logback-user/attachments/20110304/0115faac/attachment-0001.html>


More information about the Logback-user mailing list