title: How to redirect java.util.logging to a file?
body: <p>I have a java program using an external library. The main program uses <code>log4j</code> to log its messages and the library uses <code>java.util.logging</code>.</p>
  
  <p>My problem is that log messages from the external library and the main program are mixed in the console.</p>
  
  <p>I would like to redirect <strong>all</strong> log messages from the external library to a file. I tried to do that with a <code>logging.properties</code> file:</p>
  
  <pre><code>handlers= java.util.logging.FileHandler
  .level= INFO
  java.util.logging.FileHandler.pattern = foo.log
  java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
  </code></pre>
  
  <p>This file is initialized with:</p>
  
  <pre><code>System.setProperty("java.util.logging.config.file", "logging.properties");
  </code></pre>
  
  <p>Unfortunately, log messages from the external library keep appearing in the console.
  Should I use something like <code>slf4j</code> to intercept log messages from <code>java.util.logging</code>?</p>
  
  <p>Thank you for your time.</p>