[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] How to weave the method calls inside an war file?
|
Thanks Eric, thats exactly what I was looking for.
A noob question, so if a user hits the webpage, servlet is going to create a thread for the same. Now if I do logger after setting up MDC id like this:
logger.info (" Great")
So technically how this can be converted or remembered per thread?
Because imagine I did set the id as 121, and two users are hitting, which is going to be altogether different threads, how does this 121 gets binded to threads in this case?
From my understanding so if a user going to access the webpage, then he or she needs to "somehow" pass on this id to MDC, then I believe it works as required.
Correct me if I'm wrong.
Anto.
On 5 Nov 2015 16:10, "Eric B" <
ebenzacar@xxxxxxxxx> wrote:
What logging platform are you using?
If you are using Log4j, you can use the MappedDiagnosticContext (MDC) class
https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/MDC.html. This is managed on a per-thread basis, so you can assign an ID in the MDC as part of a request listener, and any Log4j call that is made in that thread will have access to the id stored in the MDC. This allows you to recall the id in a logging statement.
All logs will still be pushed to the same appender, however you would then be able to sort and/or filter based on the ID. If memory serves, retrieving the variable for the appender is done via the %X{VarName}.
I also believe that Logback has a similar MDC functionality.
Thanks,
Eric
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users