<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Russ,</p>
<p>Mailing lists are not so popular anymore nowadays, chances that a
sl4fj developer will respond here are not so good. Probably the
best thing to do is write a feature request on
<a class="moz-txt-link-freetext" href="https://github.com/qos-ch/slf4j/issues">https://github.com/qos-ch/slf4j/issues</a>. A pull request is probably
be appreciated as well!<br>
</p>
<p>Kind regards,<br>
Erik.<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">Op 25-01-2025 om 02:38 schreef Russ
Block via slf4j-user:<br>
</div>
<blockquote type="cite"
cite="mid:1250089793.3587854.1737769097501@mail.yahoo.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div class="yahoo-style-wrap"
style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;">
<div>
<div>With this method or any similar method,</div>
<div> public void info(String format, Object... arguments)
{</div>
<div> if (isInfoEnabled()) {</div>
<div> handleArgArrayCall(Level.INFO, null, format,
arguments);</div>
<div> }</div>
<div> }</div>
<div>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?</div>
<div><br>
</div>
<div>For example</div>
<div> public void setTemperature(Integer temperature) {</div>
<div> </div>
<div> oldT = t; </div>
<div> t = temperature;</div>
<div> //Sent three parameters log with two placeholders</div>
<div> //Output "Temperature set to 90. Old value was null."
The word extra is not printed</div>
<div> logger.info("Temperature set to {}. Old value was
{}.", t, oldT, "extra");</div>
<div> if(temperature.intValue() > 50) {</div>
<div> logger.info("Temperature has risen above 50
degrees.");</div>
<div> }</div>
<div> }</div>
<div><br>
</div>
<div><br>
</div>
<div>If I get into a situation where I have sent more argument
objects than placeholders that it should append those
un-placed arguments to the end of the logged string. The
intent of the developer is to have the parameter logged.
Finding this out from production is not good. What is sent
to be logged is important information, depending on the log
level.</div>
<div><br>
</div>
<div>My use case is that I want to push some legacy code to
start looking like SLF4J so we can migrate away from the
older pattern filled with isLogTraceEnabled calls. I
learned of the above when I was writing JUnit tests to see
all the things the code would do and not do.</div>
<div><br>
</div>
<div>I feel that
<a class="moz-txt-link-freetext" href="https://www.slf4j.org/faq.html#logging_performance">https://www.slf4j.org/faq.html#logging_performance</a> is
telling me that, in some way, the placeholder string
substitution is faster than appending multiple strings
together. I understood the main point of the argument as
converting items to string before I needed them was where
the overhead was. Keeping them as type Object reduces that
overhead.</div>
<div><br>
</div>
<div dir="ltr" data-setdir="false">I understand there are
Sonarqube rules and PMD to prevent me from not having the
correct number of argument objects. This would help, but I
feel like there are still going to be misses. Since my code
is custom, Sonarqube and PMD do not feel like options.</div>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre wrap="" class="moz-quote-pre">_______________________________________________
slf4j-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:slf4j-user@qos.ch">slf4j-user@qos.ch</a>
<a class="moz-txt-link-freetext" href="https://mailman.qos.ch/cgi-bin/mailman/listinfo/slf4j-user">https://mailman.qos.ch/cgi-bin/mailman/listinfo/slf4j-user</a></pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Erik van Oosten
<a class="moz-txt-link-abbreviated" href="mailto:e.vanoosten@grons.nl">e.vanoosten@grons.nl</a>
<a class="moz-txt-link-freetext" href="https://day-to-day-stuff.blogspot.com">https://day-to-day-stuff.blogspot.com</a></pre>
</body>
</html>