Reputation: 3547
I'm looking for the proper way to reference an appender that already exists to dynamically change one of its properties. With Loggers there is the LoggerFactory.getLogger as answered here, but what should I do with appenders?
Do I have to go through a logger to then get the appender? I see the AppenderFactory, but it doesn't look like what I need. This approach was shown here, but it seems like beating around the bush. The hierarchy for logback configuration has loggers and appenders at the same level. Since this wasn't the focus of the question, nothing was said about it.
Upvotes: 2
Views: 336
Reputation: 1685
I think Appenders only ever exists in the context of a logger. Also AFAIK unused appenders (appenders not attached to any loggers) are eligible for garbage collection with the exception of SocketAppender. So I think it makes sense to call logger.getAppender() to retrieve an appender (I don't think it's beating around the bush).
Upvotes: 3