Logging JVM exit (in context of JEP 486)
Michael Bien
mbien42 at gmail.com
Mon Oct 14 11:55:23 UTC 2024
Hi Matthias,
for some reason I simply assumed that JFR would also only track exit but
not halt, but it does! Works great - I sometimes forget to check the
obvious options.
(btw shutdown hooks don't run on halt, so this wouldn't work)
thanks and best regards,
michael
On 14.10.24 13:03, Baesken, Matthias wrote:
> Maybe not exactly what you want, but there is also the JFR Shutdown event https://sap.github.io/SapMachine/jfrevents/21.html#shutdown .
> This is generated in JVM_BeforeHalt :
>
> https://github.com/openjdk/jdk/blob/037f11b864734734dd7fbce029b2e8b4bc17f3ab/src/hotspot/share/prims/jvm.cpp#L436
>
>
> ( my colleague Johannes also mentioned the JVM shutdown hooks - might be also interesting for you https://www.baeldung.com/jvm-shutdown-hooks )
>
> Best regards, Matthias
>
>
>> The JVM would still be able to log something to console (in native
>> beforeHalt() or halt0()) without the application/logging callback issue?
>>
>> -Xlog:safepoint+stats=info seems to log some kind of exit cause, it is
>> the wrong way around though :)
>>
>> System.exit() / halt() will print:
>> [0,419s][info][safepoint,stats] Exit 1
>>
>> regular process exit (no-non daemon threads remaining) prints:
>>
>> [0,454s][info][safepoint,stats] Halt 1
>
More information about the jdk-dev
mailing list