Description
I have a launcher class with shutdownHook thread in main method:
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try
catch (Throwable e) {
logger.warn("something goes wrong when stopping transfer Server:\n{}",
Throwables.getStackTraceAsString(e));
} finally
}
});
In controller to stop the server, I did things below:
public void stop() {
if (transferServer.isStart())
logger.info("Server is down");
}
and in server, I stop instances like this:
public void stop() {
if (isStart()) {
running = false;
for (Map.Entry<String, TransferInstanceInterface> entry : transferInstances.entrySet()) {
TransferInstanceInterface instance = entry.getValue();
if (instance.isStart())
}
logger.info("Transfer server stopped");
}
}
and in instance I stop two thread:
public void stop() {
logger.info("Transfer instance[" + name + "] is stopping...");
if (messageListener.isStart())
{ messageListener.stop(); }if (messageProcessor.isStart())
{ messageProcessor.stop(); } running = false;
logger.info("Transfer instance[" + name + "] is down.");
}
for messageListener, I stopped is like this:
public void stop() {
logger.info("Message listener for topic[" + topic + "] is stopping...");
try {
if (running) {
running = false;
if (null != consumer)
thread.join();
logger.info("Message listener for topic[" + topic + "] is down.");
}
} catch (InterruptedException e)
}
seems that after thread.join(), all the loggers are set to level off, and won't produce any log.
What the right way to make logger produce log entries after thread.join()?