<p class="MsoNormal"><span style lang="EN-US">Hi Ceki,<br>
<br>
Sorry I was not able to explain my intention. Here is an example. </span></p>

<p class="MsoNormal"><span style lang="EN-US"> </span></p>

<p class="MsoNormal"><span style lang="EN-US">A worker
class iterates over data until a result is found. The worker allows to register
a callback that executes nextIteration() on each iteration. The callback logs
some properties that describe the progress of the worker. But writes log only on every “interval”
calls, to prevent cluttering the log, since the worker will execute a million of
iterations.</span></p>

<p class="MsoNormal"><span style lang="EN-US"><br>
Worker w = new Worker().<br>
w.addCallback(new ContinuousCallback()) {</span></p>

<p class="MsoNormal"><span style lang="EN-US"><span style></span></span></p>

<p class="MsoNormal"><span style lang="EN-US"><span style>            </span>int counter<span style>  </span>= 0;</span></p>

<p class="MsoNormal" style="text-indent:35.4pt"><span style lang="EN-US">void nextIteration() {</span></p><p class="MsoNormal" style="text-indent:35.4pt"><span style lang="EN-US"><span style>            </span>int interval = Integer.parseInt(logger.getProperty(“worker.interval”));</span></p>



<p class="MsoNormal" style="text-indent:35.4pt"><span style lang="EN-US"><span style>            </span>if
(logger.isInforEnabled() && counter++ % interval == 0) <span style> </span>{</span></p>

<p class="MsoNormal" style="text-indent:35.4pt"><span style lang="EN-US"><span style>            </span><span style>            </span>// collect attributesArray</span></p>

<p class="MsoNormal" style="text-indent:35.4pt"><span style lang="EN-US"><span style>                        </span><a href="http://logger.info">logger.info</a>(“i={},
convergence={}, ... ", attributesArray) ;</span></p>

<p class="MsoNormal" style="text-indent:35.4pt"><span style lang="EN-US"><span style>            </span>}</span></p>

<p class="MsoNormal" style="text-indent:35.4pt"><span style lang="EN-US">}<br>
}</span></p>

<p class="MsoNormal"><span style lang="EN-US"> </span></p>

<p class="MsoNormal"><span style lang="EN-US">I would
like to get the “interval” from the log configuration (eg, for logback):</span></p>

<p class="MsoNormal"><span style lang="EN-US"><configuration></span></p>

<p class="MsoNormal"><span style lang="EN-US"><span style>            </span><property name=“worker.interval”
value=“100”
/></span></p>

<p class="MsoNormal"><span style lang="EN-US"><span style>            </span><logger name="callback"
level="INFO" /></span></p>

<p class="MsoNormal"><span style lang="EN-US"></configuration></span></p>

<p class="MsoNormal"><span style lang="EN-US"> </span></p>

<p class="MsoNormal"><span style lang="EN-US">I think
that “interval” is a property that controls how data is logged and I think it
would be more elegant being able to set the property together with the logger
configuration.</span></p>

<p class="MsoNormal"><span style lang="EN-US"> </span></p>

<p class="MsoNormal"><span style lang="EN-US">There seems that I can get properties from a LoggerContext withing logback, but I understand that slf4j does not exposes
this context.</span></p>

<p class="MsoNormal"><span style lang="EN-US"> </span></p>

<p class="MsoNormal"><span style lang="EN-US">Best
regards,</span></p>

<p class="MsoNormal"><span style lang="EN-US">Daniel
Felix Ferber</span></p>

<br><div class="gmail_quote">2012/2/9 ceki <span dir="ltr"><<a href="mailto:ceki@qos.ch">ceki@qos.ch</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Hi Daniel,<br>
<br>
I don't follow you. Could you provide an *example* of what you have in mind (assume you have complete liberty with the SLF4J API) ?<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Ceki<br>
<a href="http://twitter.com/#%21/ceki" target="_blank">http://twitter.com/#!/ceki</a></font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 09.02.2012 14:45, Daniel Felix Ferber wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
I was wondering about slf4j being able to get properties defined within the<br>
configuration file form the logger framework (eg logback or log4j). Would that<br>
be a reasonable use for slf4j?<br>
<br>
1) I would configure the granularity (amount of content) of a log message that<br>
reports the result of a long-running execution.<br>
<br>
2) Also, I would configure the number of step between two log messages on a<br>
long-running task.<br>
<br>
For the first case, I could define several loggers (a simple one, a detailed<br>
one). I don't think I should use two levels, since the report cannot be<br>
considered 'info', not 'debug' or 'trace'.<br>
<br>
For the second case, I am not sure how to handle it. Currently the application<br>
has a configuration property that defines how log will behave (number of steps,<br>
amount of details). But taking it rigorously, these are not application<br>
configuration, but logger configuration.<br>
<br>
Best regards,<br>
Daniel Felix Ferber<br>
</blockquote>
<br>
<br>
______________________________<u></u>_________________<br>
slf4j-user mailing list<br>
<a href="mailto:slf4j-user@qos.ch" target="_blank">slf4j-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-user" target="_blank">http://mailman.qos.ch/mailman/<u></u>listinfo/slf4j-user</a><br>
</div></div></blockquote></div><br>