One logger per log, static final, thread-safe
One logger per log, static final, thread-safe
Answer
public final class AccessLog { private static final Logger AUDIT = Logger.getLogger("requests"); private static final Logger ERRORS = Logger.getLogger("errors"); static void bug(String where, Throwable ex) { ERRORS.log(Level.SEVERE, where, ex); } }
Two named logs, two loggers, one shared instance of each — safe because loggers are thread-safe. The three-argument `log` keeps the `Throwable`, and therefore the stack trace, which is the only part of an error-log entry anyone reads.
Harold 4e ch9 §Logging