[slf4j-user] Proper use of XLogger

ceki ceki at qos.ch
Tue May 29 10:51:40 CEST 2012


Hi Aleks,

On 28.05.2012 23:32, Aleks M wrote:
> Hello,
> I have a class in which I want to trace the method calling flow using
> XLogger entry() and exit().
> Right now I have the following line in my class:
>
> private final static Logger logger = LoggerFactory.getLogger("main");
>
> I'm also using Logback together with SLF4J.
>
> If I add the following, will this return the same logger as the first
> line, since they have the same name?:
>
> private final static XLogger trace = XLoggerFactory.getXLogger("main");

Yes, it will be the same logger that will be returned.

> I'm asking since I only want XLogger to log when I turn up my regular
> logger to TRACE level.

Settings to regular loggers will apply to Xloggers as well.

> If I now add something like:
> trace.entry(param1, param2); to each of my methods,
> will I incur a heavy performance penalty when I have a log level less
> than TRACE, e.g. ERROR? I'm asking because I can't parametrize the log
> call like I can with a regular Logger.

The entry() method will just exit if the trace level is disabled for the 
logger in question.

HTH,

-- 
Ceki
http://twitter.com/#!/ceki


More information about the slf4j-user mailing list