NDC push and pop
When we are working multi threaded environment, diagnosing a problem through a log is not easy task. we can't see one threads execution flow correctly. We can print thread name as an option. then we can grep through that thread name and find the flow. but for that you shuold have asign a proper thread name. But Think this scenario. Many messages are comming to the system and those are processed by a thread pool. we need to find a one message's flow in the log. With NDC.push() we can add message id to every log message. At the end of the flow we can remove that with NDC.pop(). Finaly after thread execution keep in mind to remove all with NDC.remove(). We need to configure log4j.xml with %x to print that pushed value.
Any way why this is like a stack push and pop ?
Labels: NDC.pop(), NDC.push()


0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home