You need to call LoggerContext's reset() or stop() methods.

Here is the code:

 import org.slf4j.LoggerFactory;
 import ch.qos.logback.classic.LoggerContext;
 ...
 LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
 lc.reset();

HTH,
--
Ceki
65% of statistics are made up on the spot

On 14.12.2012 10:40, jvm.pointer wrote:
Hi,
I`m writing an appender that sends log messages to RabbitMQ.
The appender extends ch.qos.logback.core.AppenderBase<ILoggingEvent>,
obtains connection to RabbitMQ in start() method, sends a message to
RabbitMQ in append(ILoggingEvent event) and releases that connection in
the stop() method.
The sending part works well but I`ve a problem with logback not calling
appenders` stop() method when all desktop application` threads end or
when the web app is undeployed.
I don`t know if it`s a bug or (more probably) I`m missing something but
the end result is that the stop() method is not being called, so the
connection to RabbitMQ is not released and the desktop application never
terminates and web applications cause memory leaks because of that
hanging connection.
For example tomcat reports the following:
org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/context_name] appears to have started a
thread named [AMQP Connection 127.0.0.1:5672] but has failed to stop it.
This is very likely to create a memory leak.
I'll be grateful for any suggestions and tips on how to release appender
resources on application end / undeployment.
If it`s not my wrong assumption that logback should call stop() method
to stop/deregister the appender I`ll fill in a JIRA issue.



_______________________________________________
Logback-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-user

Reply via email to