Can't get java.util.logging to work with application launched via JNLP

For debugging purposes, I would like my application to register with java.util.logging.SocketHandler. Here is my config 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 associated with the application bank and read from the main one. When I run the app offline, the logging works as expected. I see that the log entries are being pushed to localhost: 10101. However, when I run the application via JNLP, you don't see any logs. Here is my JNLP config 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 haven't found any information and see no reason why this shouldn't work. Could anyone help make this work? Or suggest another (maybe better?) Way to capture registration from an application launched via JNLP.

+3


source to share


1 answer


Well, I figured it out. It turns out my problem was how I was loading the logging properties file as a resource. I used:

ClassLoader.getSystemResourceAsStream("/com/mycompany/logging.properties");

      



But I had to use:

Main.class.getResourceAsStream("/com/mycompany/logging.properties");

      

+2


source







All Articles