Can't get Platform Logging to work
nipa at codefx.org
Fri Aug 19 15:21:33 UTC 2016
thanks for the quick reply. And you are of course right.
Luckily I don't care about the specific G1 message. After setting
everything up, I was looking for _anything_ that logs a message and that
was the first thing I came up with. Forgot the "platform classes" in the
first sentence. :(
Any idea what else I could use that logs messages via the new API?
so long ... Nicolai
On 19.08.2016 17:16, Daniel Fuchs wrote:
> 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
> best regards,
> -- daniel
>  http://openjdk.java.net/jeps/158
> On 19/08/16 16:05, Nicolai Parlog wrote:
>> 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, 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 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
>> Logger logger = System.getLogger("Application");
>> logger.log(Level.INFO, "Hello, World!");
>> so long ... Nicolai
a blog about software development
Free and Open Source Software for the City of Dortmund
More information about the core-libs-dev