I have a multi-thread program which basically has two infinite loop threads plus some GUI (Swing). My two infinite loop threads have their own log4j loggers like this:
static final Category LOG = Category.getInstance(RReceiver.class);
When in GUI I detect exit key I just do System.exit(0):
public boolean dispatchKeyEvent(KeyEvent e) {
if (e.getKeyCode()!=27 && e.getKeyCode()!=KeyEvent.VK_BACK_SPACE) return false;
System.exit(0);
return true;
}
The effect in console is like this:
DEBUG 13:07:00,940 [ Receiver] (RReceiver.java:93) - got response len:38
DEBUG 13:07:01,044 [ Receiver] (RReceiver.java:93) - got response len:38
DEBUG 13:07:01,045 [ Receiver] (RReceiver.java:93) - new status dev 4
log4j:WARN No appenders could be found for logger (com.normantech.ibcol.radiobox.RReceiver).
log4j:WARN Please initialize the log4j system properly.
The warning is not appearing always. I suspect there's wrong deinitialisation sequence, but can't figure it out. Why is that happening? I've tried to use LogManager.shutdown(); but it didn't help. I tried to finish my infinite loops nicely, but it's not best solution, because I I needed to put some additional Thread.sleep(x), tried different x, and actually was not sure if this helped.