[slf4j-user] Specify method name

Matt Sicker boards at gmail.com
Mon Feb 13 17:31:01 CET 2017


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.cartereau at 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 at qos.ch
> http://mailman.qos.ch/mailman/listinfo/slf4j-user




-- 
Matt Sicker <boards at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-user/attachments/20170213/d600cc51/attachment.html>


More information about the slf4j-user mailing list