Java Logger: Can't set log level in logger.properties file
<p>I have a java project that I use maven to build. 
I am using <strong><code>java.util.logging.Logger</code></strong> in my project and would like to configure it using a <code>logger.properties</code> file (not command line). </p>

<p>I created a <strong><code>logger.properties</code></strong> file like this:</p>

<pre><code>handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
.level=WARNING

java.util.logging.SimpleFormatter.format=[%4$s] %5$s %n

java.util.logging.config.file="../../results/api.log"
</code></pre>

<p>Here are the problems that I'm having:</p>

<ol>
<li><strong><code>java.util.logging.SimpleFormatter.format</code> is WORKING</strong>. When I change the format here, I see the change immediately in my project. So I know that at least I am importing the file correctly.</li>
<li><strong><code>.level</code> is NOT working</strong>. I've tried changing it to <code>info</code>, <code>finest</code>, <code>warning</code>, etc. but after I change it, I still see all the INFO messages even if I told it not to show INFO.</li>
<li><strong><code>java.util.logging.config.file</code> is NOT working</strong>. I kind of expected this one not to work because it is a relative path. Anyone know how I can resolve the relative path name in the properties file?</li>
</ol>

<hr>

<h1>Solution</h1>

<p>I needed to move the <code>.level</code> to the top, like this:</p>

<p><strong>logger.properties</strong></p>

<pre><code>.level=WARNING

handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler

java.util.logging.SimpleFormatter.format=[%4$s] %5$s %n
</code></pre>

<p>Then, in order to save results to "api.log", I did this in my code:</p>

<p><strong>RequestHelper.java</strong></p>

<pre><code>import org.apache.commons.io.FilenameUtils;

public class RequestHelper {

    private static final Logger LOGGER = Logger.getLogger( RequestHelper.class.getName() );

    protected RequestHelper() {
        //SET LOGGER TO OUTPUT TO "../../results/api.log"
        //Logs will ALSO output to console.
        String result_file = getNormalizedAbsolutePath("../../results/api.log");
        Handler fh = new FileHandler(result_file);
        Logger.getLogger("").addHandler(fh);
    }

    public static String getNormalizedAbsolutePath(String fileName) {
        String path;
        File file = new File(fileName);
        try {
            path = file.getCanonicalPath();
        } catch (IOException e) {
            LOGGER.warning("Error while computing the canonical path of file: " + fileName);
            path = file.getAbsolutePath();
        }
        return FilenameUtils.normalize(path);
    }
}
</code></pre>