Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

logging session ID in each entry

843844May 30 2007 — edited May 30 2007
Hi all,

I'm trying to log the session ID in each log entry, so that I'm able to see which log entry belonged to which session when analysing the log file later.

I'm using log4j and I think the right way to do stuff like this is to push the session ID to the NDC (nested diagnostic context, see http://logging.apache.org/log4j/docs/api/org/apache/log4j/NDC.html).

Now I'm having trouble to find the right place where to push this ID to the NDC and when to remove it again. The NDC is thread based, but I'm not sure how this fits into the JSF model.
I tried to use PhaseListeners, one before the RESTORE_VIEW (NDC.push()), and one after RENDER_RESPONSE (NDC.remove()), but this leads to multiple session IDs being in the NDC after a few requests.

Any idea how to fix this cleanly? Or any other approach?

Thanks a lot,
Gunnar
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 27 2007
Added on May 30 2007
2 comments
310 views