JDK: como ativar o PlatformLogger programaticamente

Preciso habilitar o log para alguma classe interna do JDK7 programaticamente.

Isto é o que eu faço na inicialização do meu aplicativo:

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

OndehttpLogger é uma referência forte (para evitar que o coletor de lixo seja coletado de lixo). Também defino o nível do ConsoleHandler para ALL. No entanto, não consigo obter nenhuma saída.

Se eu fizer isso através do arquivo de configuração de log, ele funcionará conforme o esperado.

Posso estar errado, mas acho que isso tem algo a ver comigo, não entendendo oPlatformLogger que foi introduzido no Java 7 e que - afaik - agora é usado para todo o log interno do JDK. Ou talvez eu simplesmente não entenda J.U.L. bom o bastante.

Eu estou supondo que funcionaria se eu fizesse:

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

masPlatformLogger classe está em um pacote que não posso referenciar.

O que éPlatformLogger ?

Aqui está o 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