Hello Russ,

On 24/01/2025 19:46, slf4j developers list via slf4j-dev wrote:

Thank you for your comments.

With this method or any similar method,
     public void info(String format, Object... arguments) {
         if (isInfoEnabled()) {
             handleArgArrayCall(Level.INFO, null, format, arguments);
         }
     }
If the number of objects in 'arguments' is more than the number of placeholders, {}, the extra argument objects are not logged.  Is there a reason for that?

The reason is that catering for this eventuality would be relatively complicated. More importantly, I think that it is not SLF4J's responsibility to fix every possible error that could be made by the programmer.

For example
   public void setTemperature(Integer temperature) {
     oldT = t;
     t = temperature;
   //Sent three parameters log with two placeholders
  //Output "Temperature set to 90. Old value was null."  The word extra is not printed     logger.info("Temperature set to {}. Old value was {}.", t, oldT, "extra");
     if(temperature.intValue() > 50) {
       logger.info("Temperature has risen above 50 degrees.");
     }
   }

The fluent API allows adding key value pairs which should avoid this pitfall.

Best regards,

--
Ceki Gülcü

Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch

_______________________________________________
slf4j-dev mailing list
slf4j-dev@qos.ch
https://mailman.qos.ch/cgi-bin/mailman/listinfo/slf4j-dev

Reply via email to