Can't get Platform Logging to work
Nicolai Parlog
nipa at codefx.org
Fri Aug 19 15:21:33 UTC 2016
Hi Daniel,
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
> [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.LoggerFi
nder.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