An interesting approach would be to redirect gc.log to the named pipe -Xloggc:/my/named/pipe How to write the GC log to the named pipe
then read the pipe forms the application itself: How to open a Windows named pipe with Java?
and write to an arbitrary (for example, asynchronous) error log from the code.
Tried this on a windows machine. Unfortunately, it is harder to configure on Windows than on Linux.
On Windows, it works mainly with an optional Powershell script (there may also be a dedicated application). This sample project also contains a demo application that you can use immediately to check if GC logs are redirected to Logback through SLF4J.
source share