Do we need to use MDC variable to append info to logger messages

Assume we have login controller where we identify user, company, session id, time etc.,

Now we want to add all these info by default in logger messages

Do we need to use MDC variable to put the key and values and log4j properties file needs to be defined as {sessionId}

MDC.put("sessionId", "121212");

Is this is the right approach or we need to do in a different way ?

Thanks.
Software ProgrammerAsked:
Who is Participating?
 
girionisCommented:
Unfortunately this is the easiest approach. You might as well write your own appender that will give you more flexibility.
0
 
Software ProgrammerAuthor Commented:
Thanks for the confirmation
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.