<div dir="ltr"><div>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.</div><div><br></div><div>The parameter to the aspect (interceptor) class is of type org.aspectj.lang.JoinPoint. Obtain the method name with getSignature().getName().</div><div><br></div><div>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.</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 13, 2017 at 10:31 AM, Matt Sicker <span dir="ltr"><<a href="mailto:boards@gmail.com" target="_blank">boards@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Well, I see three ways you can do this:<div><br></div><div>1. Enable location information in the pattern layout. This is slow, however, but so is using java.util.logging instead.</div><div>2. Since you're already using Log4j 2, you can use log4j-api's Logger.traceEntry() and Logger.traceExit() methods <<a href="https://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/Logger.html#traceEntry()" target="_blank">https://logging.apache.org/lo<wbr>g4j/2.x/log4j-api/apidocs/org/<wbr>apache/logging/log4j/Logger.<wbr>html#traceEntry()</a>>.</div><div>3. Emulate the tracing functionality by just using Logger.trace() with markers for entry/exit.</div></div><div class="gmail_extra"><div><div class="m_729953001942578013h5"><br><div class="gmail_quote">2017-02-13 7:57 GMT-06:00 CARTEREAU Benjamin <span dir="ltr"><<a href="mailto:benjamin.cartereau@cnav.fr" target="_blank">benjamin.cartereau@cnav.fr</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I would like to log method entry/exit with slf4j through an Interceptor that knows the name of the called/intercepted method.<br>
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.<br>
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.<br>
Is there a way to accomplish this (like it is possible through JUL entering/exiting methods) or could it require XLogger evolutions ?<br>
<br>
Regards<br>
******************************<wbr>******************************<wbr>*****************************<br>
<br>
<br>
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.<br>
<br>
En aucun cas, le contenu de ce message ne peut valoir offre ou acceptation ou engagement de la part de la CNAV.<br>
<br>
Les opinions contenues dans ce message sont personnelles à l'émetteur.<br>
<br>
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.<br>
______________________________<wbr>_________________<br>
slf4j-user mailing list<br>
<a href="mailto:slf4j-user@qos.ch" target="_blank">slf4j-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-user" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/<wbr>listinfo/slf4j-user</a></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="m_729953001942578013HOEnZb"><font color="#888888">-- <br><div class="m_729953001942578013m_5845047053968969730gmail_signature" data-smartmail="gmail_signature">Matt Sicker <<a href="mailto:boards@gmail.com" target="_blank">boards@gmail.com</a>></div>
</font></span></div>
<br>______________________________<wbr>_________________<br>
slf4j-user mailing list<br>
<a href="mailto:slf4j-user@qos.ch" target="_blank">slf4j-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-user" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/<wbr>listinfo/slf4j-user</a><br></blockquote></div><br></div></div>