java - Thread id not showing in logs -



java - Thread id not showing in logs -

my applications listens messages on queue , publishes results tibco subject. have written message listener called via "onmessage" method of "messagelistener"

problem facing threads in logs show same thread name i.e. "tibco ems session dispatcher (21367271)". , making hard track thread doing what.

my log4j look "%d{hh:mm:ss,sss} %-5p %c{1} [%t] - %m%n" .

what alter need create proper thread id?

edit:

i want able differentiate between log messages printed processing of different messages. @ nowadays can't thread name.

you free set name of thread like. do:

private static atomicinteger count = new atomicinteger(0); public void onmessage(message message) { string oldname = thread.currentthread().getname(); thread.currentthread.setname("my-thread-" + count.getandincrement()) seek { // ... existing code ... } { thread.currentthread().setname(oldname); } }

an alternate atomic integer uniquely identifying thread utilize identity hash code:

thread.currentthread.setname("my-thread-" + system.identityhashcode());

java multithreading log4j jms

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -