Hi Nicolai,
Log messages emitted by the JVM are not emitted through
the System.Logger API. JEP 264 is a pure Java API which
aims at replacing the sun.util.logging.PlatformLogger
implementation.
I believe what you are looking for is JEP 158
Unified JVM Logging [1]
best regards,
-- daniel
[1] http://openjdk.java.net/jeps/158
On 19/08/16 16:05, Nicolai Parlog wrote:
Hi!
I'm trying out JEP 264: Platform Logging API and Service but can't get
it to work (or misunderstood something).
My understanding is that the JVM should use the provided LoggerFinder to
log its own messages. So when I start with "-verbose:gc" I expected the
message "Using G1" to go through my logger implementation - but it doesn't.
I've set up a demo project[1], in which I'm creating a modules `logger`,
which provides `LoggerFinder`, and `app`, which holds the started
application. I launch with:
java -verbose:gc -mp out/mods -m org.codefx.demo.java9.app
The messages I send from the app module go through my logger, so the
service module gets picked up. But the G1 message doesn't. :( I noticed
that the docs[2] say this:
First it finds any custom LoggerFinder provider using the
ServiceLoader facility with the system class loader.
Do I have to do anything differently to make my service available to the
system class loader?
On a tangent, I also wondered what would be the preferred way to log
from inside my code. Should I use System::getLogger directly?
Logger logger = System.getLogger("Application");
logger.log(Level.INFO, "Hello, World!");
so long ... Nicolai
[1]
https://github.com/CodeFX-org/demo-java-9/tree/master/src/org/codefx/demo/java9/api/platform_logging
[2]
http://download.java.net/java/jdk9/docs/api/java/lang/System.LoggerFinder.html