Can't get Platform Logging to work
Nicolai Parlog
nipa at codefx.org
Fri Aug 19 15:05:38 UTC 2016
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
--
PGP Key:
http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509
Web:
http://codefx.org
a blog about software development
http://do-foss.de
Free and Open Source Software for the City of Dortmund
Twitter:
https://twitter.com/nipafx
More information about the core-libs-dev
mailing list