For debugging purposes, I would like my app to log to a java.util.logging.SocketHandler. Here’s, my configuration file:
handlers = java.util.logging.SocketHandler
.level = WARNING
java.util.logging.SocketHandler.level = ALL
java.util.logging.SocketHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SocketHandler.host = localhost
java.util.logging.SocketHandler.port = 10101
com.mycompany.level = ALL
This logging configuration file is bundled with the app’s jar and read from main. When I launch the app standalone, the logging works as expected. I see log statements streaming to localhost:10101. However, when i launch the app via JNLP is see no logging. Here’s my JNLP configuration file:
<jnlp spec="1.0+" codebase="http://mycompany.com" href="myapp.jnlp">
<information>
<title>My App</title>
<vendor>My Company</vendor>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+"/>
<jar href="myapp.jar"/>
</resources>
<application-desc main-class="com.mycompany.Main"/>
</jnlp>
I have not found any information nor do I see any reason why this shouldn’t work. Could someone please help make this work? Or suggest another (maybe better?) way to capture logging from an app launched via JNLP.
Well, I figured it out. It turns out my problem was how I was loading the logging properties file as a resource. I was using:
But I should have used: