dcsimg
NDC/MDC in log4j
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Nitin_Nair
Posted On:   Friday, May 2, 2003 03:40 AM

I am working in a project where for an EJB environment for logging the messages we are using Log4j. Here we are using nested diagnostics contexts (NDC)/MDC to differentiate logging requests from different clients. The control flow in my application is as follows :- Servlet1 --> Servlet2 --> EJB [ 1... n] Also as usual there are bean to bean calls. The NDC.push(hostname) is being done in the "doPost(HttpServletRequest req, HttpServletResponse res)" of Servlet 1. Currently what is happening is, on using NDC/MDC, all the logger stmts in Servlet1 are getting printed properly with correct user name. But the moment control comes in Servelt2 onwards, the user info is getting missed out.Is there sometin   More>>

I am working in a project where for an EJB environment for logging the messages we are using Log4j. Here we are using nested diagnostics contexts (NDC)/MDC to differentiate logging requests from different clients.
The control flow in my application is as follows :-

Servlet1 --> Servlet2 --> EJB [ 1... n]

Also as usual there are bean to bean calls.

The NDC.push(hostname) is being done in the "doPost(HttpServletRequest req, HttpServletResponse res)" of Servlet 1.
Currently what is happening is, on using NDC/MDC, all the logger stmts in Servlet1 are getting printed properly with correct user name. But the moment control comes in Servelt2 onwards, the user info is getting missed out.Is there someting in particular which needs to be taken care of ??? Or How do we achieve this?


NFO - [NITIN.pune.tcs.co.in] [ExecuteThread: '11' for queue: 'default'] - Calling CreateRequest ("ServiceCall" , svcName) on the class RequestFactory
INFO - [NITIN.pune.tcs.co.in] [ExecuteThread: '11' for queue: 'default'] - Making a ervice call request inside CreateRequest(String request , String subject) of class RequestFactory
INFO - [NITIN.pune.tcs.co.in] [ExecuteThread: '11' for queue: 'default'] - Calling SendRequest (sreq,secure) on the class WebArchUtil
INFO - [] [ExecuteThread: '12' for queue: 'default'] - While creating ThreadSpecificContext, type is UTCS
INFO - [] [ExecuteThread: '12' for queue: 'default'] - In setBeanContext, type is UTCS
INFO - [] [ExecuteThread: '12' for queue: 'default'] - dataSource is weblogic.jdbc.common.internal.RmiDataSource@340272
INFO - [] [ExecuteThread: '12' for queue: 'default'] - DataSource is weblogic.jdbc.common.internal.RmiDataSource@340272
INFO - [] [ExecuteThread: '12' for queue: 'default'] - SQL Statement is select AuditFlg from BT_TBL_AUD where BT_Name = ?
INFO - [] [ExecuteThread: '12' for queue: 'default'] - SQL Statement is insert into Tbl_licagentdetails ( LICAgentNo ,LICAgentName ,LICAgentAddress ,Tbl_licagentdetails_ver ,DM_LstUpdDt ) VALUES ( ?,?,?,? , ? )
INFO - [NITIN.pune.tcs.co.in] [ExecuteThread: '11' for queue: 'default'] - The action to be performed is 0
My output log is showing something like this:


Regards
Nitin

   <<Less
About | Sitemap | Contact