Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set up java logging using a properties file? (java.util.logging)
    text
    copied!<p>I have a stupid java logging problem: I'm loading the logging configuration from my app configuration file - but it just doesn't log anything after reading the file (which looks pretty much like the examples you will find on the net except for the additional application configuration - removing this also doesn't help). The "initializing..." log line appears just fine, but the "starting app" and any further messages are neither logged to the console, nor is the logfile ever created. What am I missing here?</p> <p>The Logger code looks like this:</p> <pre><code>... Logger log = Logger.getLogger("myApp"); log.setLevel(Level.ALL); log.info("initializing - trying to load configuration file ..."); Properties preferences = new Properties(); try { FileInputStream configFile = new FileInputStream("/path/to/app.properties"); preferences.load(configFile); LogManager.getLogManager().readConfiguration(configFile); } catch (IOException ex) { System.out.println("WARNING: Could not open configuration file"); System.out.println("WARNING: Logging not configured (console output only)"); } log.info("starting myApp"); ... </code></pre> <p>And this is the configuration file:</p> <pre><code>appconfig1 = foo appconfig2 = bar # Logging handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler .level = ALL # File Logging java.util.logging.FileHandler.pattern = %h/myApp.log java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter java.util.logging.FileHandler.level = INFO # Console Logging java.util.logging.ConsoleHandler.level = ALL </code></pre>
 

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