This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Other Open Source Projects and the fly likes NDC not doing its bit properly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "NDC not doing its bit properly" Watch "NDC not doing its bit properly" New topic

NDC not doing its bit properly

Akash Bhatt

Joined: Jul 26, 2005
Posts: 25
I am devloping a Web Application with EJBs on WebSphere. Log4j is being used to log the user actions. I am using NDC to specify the user specific information on the logs generated. The problem is that sometimes NDC works and sometimes it does not. I dont have a clue why it does so. 'NDC.push()' is included in the LoginModule so that we have the thread information containing the user login info. Similary 'NDC.pop()' is used when the user logs out.
A sample of log is included:
[DATE][<used by NDC>]\n[Calling Class][LEVEL]->[Message]\n\n

[%d{dd/MM/yyyy HH:mm:ss,SSS}][%53.53x]%n[%-15.15c][%-5.5p]->[%m]%n%n

[21/07/2006 12:28:49,000][ ]
[war.CoisServlet][INFO ]->[Servlet Initializing...!!]

[21/07/2006 12:29:42,172][ Sess from @ 2006-07-21 12:29:42.125]
[war.CoisServlet][INFO ]->[USER logins the app as akash akash]

[21/07/2006 12:29:42,172][ Sess from @ 2006-07-21 12:29:42.125]
[war.CoisServlet][INFO ]->[Going for Login through Servlet]

[21/07/2006 12:29:42,375][ Sess from @ 2006-07-21 12:29:42.125]
[nbean.LoginBean][INFO ]->[IN UserInfo doLogin asAKASHAKASHc6v5fr62fY5sZD5TkWzwbiF]

[21/07/2006 12:29:42,594][ Sess from @ 2006-07-21 12:29:42.125]
[nbean.LoginBean][INFO ]->[checking ip s]

[21/07/2006 12:29:42,938][ Sess from @ 2006-07-21 12:29:42.125]
[nbean.LoginBean][INFO ]->[ui -> AKASH DLI NDLS AKASH O NR 1234 CRIS01 1979 true]

[21/07/2006 12:29:43,391][ Sess from @ 2006-07-21 12:29:42.125]
[war.CoisServlet][INFO ]->[Returning form Login Bean]

[21/07/2006 12:30:06,547][ ]
[war.CoisServlet][INFO ]->[USER -> Initiating Yard Stock Entry for Coach]

[21/07/2006 12:30:06,969][ ]
[war.CoisServlet][INFO ]->[System -> Collected data returning to YardStkImp.jsp]

[21/07/2006 12:30:24,031][ ]
[war.CoisServlet][INFO ]->[USER -> Initiating Submission]

[21/07/2006 12:30:24,062][ ]
[war.CoisServlet][INFO ]->[SYSTEM -> Going into Bean with data]

[21/07/2006 12:30:24,172][ ]
[.YardStkImpBean][INFO ]->[SYSTEM -> In Yard Stk Bean]

[21/07/2006 12:30:28,266][ ]
[war.CoisServlet][INFO ]->[SYSTEM -> Bean Op Completed. Going to YardStkImp.jsp]

[21/07/2006 12:30:28,469][ ]
[war.CoisServlet][INFO ]->[SYSTEM -> Operation Done]

[21/07/2006 12:32:43,062][ Sess from @ 2006-07-21 12:29:42.125]
[war.CoisServlet][INFO ]->[.. going for logout...!!]

[21/07/2006 12:32:43,094][ Sess from @ 2006-07-21 12:29:42.125]
[war.CoisServlet][INFO ]->[..SUCCESSFULL LOGOUT...!!.. thruu servlet]

...ToucH SkieS
SCJP 1.4 86%
SCWCD 1.4 82%
Kumar Mettu

Joined: Mar 01, 2008
Posts: 6

Thats not how NDC works. You need to use NDC (Push and POP) per request not for whole session.


<A href="">My Blog</A>
It is sorta covered in the JavaRanch Style Guide.
subject: NDC not doing its bit properly