I've done this regularly with Spring Aspects/AspectJ. Configure aspects outside of code (e.g. which packages, classes, methods, includes using wildcards, to apply the aspect to), so a trace logging aspect allows externally configuring the trace logging, eliminating manually adding log statements to source files.
The parameter to the aspect (interceptor) class is of type org.aspectj.lang.JoinPoint. Obtain the method name with getSignature().getName(). This is not what you asked for (with XLogger), but it is the most minimal impact and most powerful approach I know of. You may find use for additional aspects too. On Mon, Feb 13, 2017 at 10:31 AM, Matt Sicker <boa...@gmail.com> wrote: > Well, I see three ways you can do this: > > 1. Enable location information in the pattern layout. This is slow, > however, but so is using java.util.logging instead. > 2. Since you're already using Log4j 2, you can use log4j-api's > Logger.traceEntry() and Logger.traceExit() methods < > https://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/ > apache/logging/log4j/Logger.html#traceEntry()>. > 3. Emulate the tracing functionality by just using Logger.trace() with > markers for entry/exit. > > 2017-02-13 7:57 GMT-06:00 CARTEREAU Benjamin <benjamin.carter...@cnav.fr>: > >> Hello, >> >> I would like to log method entry/exit with slf4j through an Interceptor >> that knows the name of the called/intercepted method. >> I have found out that XLogger makes it possible to log that kind of >> activity (entry/exit of a method) but the method name cannot be specified. >> And since I am in an interceptor class and not the real class/method, I >> cannot rely on my logging implementation (log4j2) that could output the >> method name where the logging request was issued. >> Is there a way to accomplish this (like it is possible through JUL >> entering/exiting methods) or could it require XLogger evolutions ? >> >> Regards >> ************************************************************ >> ***************************** >> >> >> Ce message électronique, les éventuels fichiers joints et les >> informations qu'il contient, peuvent être couverts par le secret >> professionnel et sont exclusivement adressés à son destinataire. Si vous le >> recevez par erreur, merci d'en informer l'expéditeur et de le détruire. A >> ce titre, toute diffusion non autorisée de ce message, même partielle, sous >> quelque forme que ce soit, est interdite et punie par la loi. >> >> En aucun cas, le contenu de ce message ne peut valoir offre ou >> acceptation ou engagement de la part de la CNAV. >> >> Les opinions contenues dans ce message sont personnelles à l'émetteur. >> >> Il est de la responsabilité du destinataire de s'assurer que le message >> et ses éventuelles pièces jointes ne contiennent pas de virus informatique. >> _______________________________________________ >> slf4j-user mailing list >> slf4j-user@qos.ch >> http://mailman.qos.ch/mailman/listinfo/slf4j-user > > > > > -- > Matt Sicker <boa...@gmail.com> > > _______________________________________________ > slf4j-user mailing list > slf4j-user@qos.ch > http://mailman.qos.ch/mailman/listinfo/slf4j-user >
_______________________________________________ slf4j-user mailing list slf4j-user@qos.ch http://mailman.qos.ch/mailman/listinfo/slf4j-user