There is somehow complex scenarion in background.
We are having axis WebService and using log4j for logging. To simplify
testing of our product we creted small wrapper accross log4j so we can provide log data in WS's response. In that way we can check what is logged in that specific request without opening log data.
We decide to intercept log4j's calls and write them into static hash map LOG_DATA<ThreadId, StringBuilder>. We are using ThreadId because we will get same id accross one request.
Here is simplified version of our logging info method:
info(message) {
log4j.info(message)
if (user wanna to log in request) {
LOG_DATA.get(current_thread_id).append(message)
}
}
When reqest finishes we are dunping LOG_DATA into response (using current ThreadId as key).
Now, we are having some issues, because in one point of request we are creating couple of threads to do some paralel processing and main request will wait until they are finished. Problem is now ThreadId - newly created threads are having different thread id's and they will not log into same entry in LOG_DATA.
To resovle this I need somehow to find thread's parent id.
Also there is other problems, because some threads are created from java.lang.Thread, others are from concurrent package, there are others which is created by thord party, ... and i need those logs also - so i cannot simply create ThreadGroup and put all child treads into thath group.