JDK: jak programowo włączyć PlatformLogger

Muszę programowo włączyć rejestrowanie niektórych wewnętrznych klas JDK7.

Oto co robię podczas inicjalizacji mojej aplikacji:

httpLogger = Logger.getLogger("sun.net.www.protocol.http.HttpURLConnection");
httpLogger.setLevel(Level.FINEST);

gdziehttpLogger jest silnym odniesieniem (aby uniknąć zbierania śmieci przez logger). Ustawiłem także poziom ConsoleHandler na ALL. Jednak nie mogę uzyskać żadnego wyjścia.

Jeśli zrobię to poprzez rejestrowanie pliku konfiguracyjnego, działa zgodnie z oczekiwaniami.

Mogę się mylić, ale myślę, że ma to coś wspólnego ze mną, nie rozumiemPlatformLogger który został wprowadzony w Javie 7 i który - afaik - jest teraz używany do wszystkich wewnętrznych protokołów JDK. A może po prostu nie rozumiem J.U.L. wystarczająco dobrze.

Zgaduję, że zadziałałoby, gdybym:

httpLogger = PlatformLogger.getLogger("sun.net.www.protocol.http.HttpURLConnection");
httpLogger.setLevel(Level.FINEST);

alePlatformLogger klasa jest w pakiecie, którego nie mogę odnieść.

Co jestPlatformLogger ?

Oto JavaDoc:

Platform logger provides an API for the JRE components to log
messages.  This enables the runtime components to eliminate the
static dependency of the logging facility and also defers the
java.util.logging initialization until it is enabled.
In addition, the PlatformLogger API can be used if the logging
module does not exist.

If the logging facility is not enabled, the platform loggers
will output log messages per the default logging configuration
(see below). In this implementation, it does not log the
the stack frame information issuing the log message.

When the logging facility is enabled (at startup or runtime),
the java.util.logging.Logger will be created for each platform
logger and all log messages will be forwarded to the Logger
to handle.

Logging facility is "enabled" when one of the following
conditions is met:
1) a system property "java.util.logging.config.class" or
    "java.util.logging.config.file" is set
2) java.util.logging.LogManager or java.util.logging.Logger
    is referenced that will trigger the logging initialization.

Default logging configuration:
  global logging level = INFO
  handlers = java.util.logging.ConsoleHandler
  java.util.logging.ConsoleHandler.level = INFO
  java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

Limitation:
<JAVA_HOME>/lib/logging.properties is the system-wide logging
configuration defined in the specification and read in the
default case to configure any java.util.logging.Logger instances.
Platform loggers will not detect if <JAVA_HOME>/lib/logging.properties
is modified. In other words, unless the java.util.logging API
is used at runtime or the logging system properties is set,
the platform loggers will use the default setting described above.
The platform loggers are designed for JDK developers use and
this limitation can be workaround with setting
-Djava.util.logging.config.file system property.

@since 1.7

questionAnswers(2)

yourAnswerToTheQuestion