Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed to close additional FileHandler for JUL?
    primarykey
    data
    text
    <p>I'm using java util logging for logging in a small Java EE application. To add an additional FileHandler (for example for errors/warnings), I created a LoggerFactory that creates the actual logger and that statically add a filehandler to the "main" logger.</p> <pre><code>package de.il.myapp.logging; public class LoggerFactory { private static final java.util.logging.Logger MAIN_LOGGER = java.util.logging.Logger.getLogger("de.il.myapp"); static { try { final java.util.logging.FileHandler fh = new java.util.logging.FileHandler("error.log", 1024*1024, 5, true); fh.setLevel(Level.WARNING); final java.util.logging.Formatter formatterTxt = new java.util.logging.SimpleFormatter(); fh.setFormatter(formatterTxt); MAIN_LOGGER.addHandler(fh); } catch (final IOException e) { //... } } } public static final Logger getLogger(final Class&lt;?&gt; clazz){ return java.util.logging.Logger.getLogger(clazz); } } </code></pre> <p>Everything works fine, except, when I stop the application, the lck file are still there. On a start, a new lck is created. So after some restarts the directory looks like this.</p> <pre><code> error.log.0 error.log.0.1 error.log.0.1.lck error.log.0.2 error.log.0.2.lck error.log.0.3 error.log.0.3.lck error.log.0.lck </code></pre> <p>The question is: How can I avoid this? Do I have to close the filehandler at the end? But where? Since this is a Java EE application I don't you an exit point, do I? And why do I get ..log.0.X for the logfiles, not just ..log.0? </p> <p>Thanks, Ingo</p>
    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.
    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