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 ?

Software ProgrammerAsked:
Who is Participating?
Unfortunately this is the easiest approach. You might as well write your own appender that will give you more flexibility.
Software ProgrammerAuthor Commented:
Thanks for the confirmation
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.