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" <ebenza...@gmail.com> 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 > > > > On Thu, Nov 5, 2015 at 9:34 AM, ants <anto.aravinth....@gmail.com> wrote: > >> I have few questions on this specific task; Now I have written by >> monitoring >> logic in the aspectj. It works so smoothly and tested in tomcat and other >> servers as well. >> >> I was wondering, if this can be done as well: >> >> 1. The logging gets started when I turn on few params on my aspectj jar, >> which starts logging. >> 2. So if possible, when it logs, can I make it to log according to each >> thread level? >> >> What I was thinking over here is this, I will start my logging param in >> aspectj, so imagine, when two users access the webpage in the server, now >> I >> want the trace should be completely isolated from each of the request. I >> know HTTP doesn't have states, we can do this in sort of attaching some >> "sessionID" to each trace, and then do a batch operation for getting the >> result of each thread; so that trace "flow" is perfect. >> >> I just want to know if there are any other ways of doing this? >> >> Your thoughts will be really helpful to me. >> >> >> >> -- >> View this message in context: >> http://aspectj.2085585.n4.nabble.com/How-to-weave-the-method-calls-inside-an-war-file-tp4651913p4651968.html >> Sent from the AspectJ - users mailing list archive at Nabble.com. >> _______________________________________________ >> aspectj-users mailing list >> aspectj-users@eclipse.org >> To change your delivery options, retrieve your password, or unsubscribe >> from this list, visit >> https://dev.eclipse.org/mailman/listinfo/aspectj-users >> > > > _______________________________________________ > aspectj-users mailing list > aspectj-users@eclipse.org > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > https://dev.eclipse.org/mailman/listinfo/aspectj-users >
_______________________________________________ aspectj-users mailing list aspectj-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/aspectj-users