[slf4j-user] logger.info("It took {%h hours %m minutes %s seconds}.", timeTakenInMilliseconds)

Ceki Gulcu ceki at qos.ch
Tue May 26 17:26:33 CEST 2009


Hello Geoffrey,

Geoffrey De Smet wrote:
> Hi,
> 
> Is it possible to do something like this?
> 
> int timeTakenInMilliseconds) = 3662000;
> logger.info("It took {hh:mm:ss} seconds", timeTakenInMilliseconds);
> 
> which prints this to the log:
> 
> "It took 1 hours 1 minutes 2 seconds."
> 
> The idea is that the timeTakeInMilliseconds is only parsed if info 
> logging is on.

> Is String.printf syntax allowed in the format of logger.info(format, args)?

No. SLF4J message formatter only perform simple toString conversion on objects. 
It does not support printf syntax.


-- 
Ceki Gülcü
The complete log4j manual: http://www.qos.ch/log4j/



More information about the slf4j-user mailing list