You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Digambar, Shaligram (Consultant)" <Sh...@GTECH.COM> on 2003/08/15 18:08:10 UTC

logging multiple users using NDC

Hello,
In our web application we have a JSP->Struts->EJB->Database dataFlow for
each user. I am using log4j for logging the data to a log file and
logFactor5 to display log from the log file. I am interested in sorting the
logs for each user based on the user ID. Mulitple users can log into the web
app at same time from different browsers. Currently the NDC is implemented
as below
->in login action servelet write NDC.push(userID)
->log debug messages in other JSPs and Actions and EJBs 
->in logoff action write NDC.pop(), NDC.remove()
 
This works well for one user e.g. it produces output like user123,"debug
message1"; user123 "infomessage1"   and so on.
The problem comes when another user say userABC logs in while user123 is
still logged in. The output log looks like user123 user456,"debug message1";
user123 user456,"infomessage1"   and so on.
 
I need a separate log record for each userID and I need to differentiate the
log records based on the userID. How can I accomplish that? Since the NDC
stack is global, it gets appeded for each user if the previous user is not
popped. Is there any other way to implement this?

Thanks,
Shaligram

Phone: (401)392-7948
Fax:(401)392-4974/4975



-----------------------------------------
This email may contain confidential and privileged material for the sole use of the intended recipient(s). Any review, use, retention, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message.  Also, email is susceptible to data corruption, interception, tampering, unauthorized amendment and viruses. We only send and receive emails on the basis that we are not liable for any such corruption, interception, tampering, amendment or viruses or any consequence thereof.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org