Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy are the Level.FINE logging messages not showing?
    primarykey
    data
    text
    <p>The <a href="http://download.oracle.com/javase/8/docs/api/java/util/logging/Level.html" rel="noreferrer">JavaDocs for <code>java.util.logging.Level</code></a> state:</p> <hr> <p>The levels in descending order are:</p> <ul> <li><code>SEVERE</code> (highest value)</li> <li><code>WARNING</code></li> <li><code>INFO</code></li> <li><code>CONFIG</code></li> <li><code>FINE</code></li> <li><code>FINER</code></li> <li><code>FINEST</code> (lowest value) </li> </ul> <hr> <h2>Source</h2> <pre><code>import java.util.logging.*; class LoggingLevelsBlunder { public static void main(String[] args) { Logger logger = Logger.getAnonymousLogger(); logger.setLevel(Level.FINER); System.out.println("Logging level is: " + logger.getLevel()); for (int ii=0; ii&lt;3; ii++) { logger.log(Level.FINE, ii + " " + (ii*ii)); logger.log(Level.INFO, ii + " " + (ii*ii)); } } } </code></pre> <h2>Output</h2> <pre><code>Logging level is: FINER Jun 11, 2011 9:39:23 PM LoggingLevelsBlunder main INFO: 0 0 Jun 11, 2011 9:39:24 PM LoggingLevelsBlunder main INFO: 1 1 Jun 11, 2011 9:39:24 PM LoggingLevelsBlunder main INFO: 2 4 Press any key to continue . . . </code></pre> <h2>Problem statement</h2> <p>My example sets the <code>Level</code> to <code>FINER</code>, so I was expecting to see 2 messages for each loop. Instead I see a single message for each loop (the <code>Level.FINE</code> messages are missing).</p> <h2>Question</h2> <p>What needs changing in order to see the <code>FINE</code> (, <code>FINER</code> or <code>FINEST</code>) output?</p> <h2>Update (solution)</h2> <p>Thanks to <a href="https://stackoverflow.com/questions/6315699/why-are-my-level-fine-logging-messages-not-showing/6315736#6315736">Vineet Reynolds' answer</a>, this version works according to my expectation. It displays 3x<code>INFO</code> messages, &amp; 3x<code>FINE</code> messages.</p> <pre><code>import java.util.logging.*; class LoggingLevelsBlunder { public static void main(String[] args) { Logger logger = Logger.getAnonymousLogger(); // LOG this level to the log logger.setLevel(Level.FINER); ConsoleHandler handler = new ConsoleHandler(); // PUBLISH this level handler.setLevel(Level.FINER); logger.addHandler(handler); System.out.println("Logging level is: " + logger.getLevel()); for (int ii=0; ii&lt;3; ii++) { logger.log(Level.FINE, ii + " " + (ii*ii)); logger.log(Level.INFO, ii + " " + (ii*ii)); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload