multithreading - console logging inside a thread is not accurate -
i'm using logback implementation , created asyncappender
use logging inside thread.
the thread monitor: consumes blockingqueue
of objects added other threads , while queue not empty, , there no blocking signal logs content of queue. @ same time, queue filled few threads.
when threads stopping signal coordinator, interrupt, don't add more content in queue.
the monitor queue interrupts once there blocking signal (the producer threads interrupted) , blockingqueue
empty.
there 2 problems logging of monitor thread:
after producers have interrupted, queue becomes empty monitor thread interrupts immediately, without showing of contents of queue, when removed queue.
the order of shown messages (both in console appender , file appender) not same have been inserted in queue
i tried 3 different approaches: creating static logger inside thread, creating non-static 1 , providing loader class monitor thread created.
in case in while(true){} loop in monitor thread, shown not in right order, plus fact have find out how interrupt thread.
i checked case of mdc
problem somehow different: have consume product of producers , while producing, plus after finished in case there still stuff in queue.
i checked loggercontext
inside thread , it's started false. shouldn't true;
any idea on how can show content before interrupting thread , show in right order, valuable.
thanks.
Comments
Post a Comment