In something like a servlet engine one thread usually handles one user
request until that request is done. Then you can set the username in
the MDC and it will be logged correctly. How is your application
different? Does one thread handle multiple users at the same time?
On 2/21/07, Sriram Sundararajan <[EMAIL PROTECTED]> wrote:
Hi,
I am using Log4j for a web oriented project, where i have to log the
messages with logged in user id and his name.
Each and every time i don't want to pass the userid and username from
the session like below.
logger.debug("<userid>","<username>","<messages.....>");//i don't want
to do this
I want to use something similar to below statement. But in the log file i
have to see the userid and user name
logger.debug("<messages.....>");//i want to do this
I tried to use MDC and NDC, but for each and every call i need to set this
value before making a call....
MDC.put("userid',<....>);
MDC.put("username',<....>);
Only for one time i want to set this value, after that i don't want to do
that. If you know any design patterns for this it will be of great help.
regards
sri
--
James Stauffer http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]