I’ve been trying to do some “custom” logging in Glassfish the last week and am completely stuck. It would appear, based on not being able to find anything, that nobody has run into the same problem but I find it hard to believe that nobody has wanted to use the java.util.logging.SocketHandler.
My application used to use log4j but since changing to Sun AS/Glassfish it seemed pointless to keep using log4j given that Glassfish uses Sun’s java.util.logging framework internally. I want to be able to set logging levels via the administration console and that simply isn’t possible with log4j. Since the app does use Commons Logging it was a simple matter to get the application logging plugged into the app server and have the logging levels set via the console. I thought it would be as easy to add SocketHandler into the mix so that I could use Chainsaw (or Logfeeder).
The administration console lets you add an additional, “custom”, log handler. I am supposed to specify the full class name which I did – java.util.logging.SocketHandler. In “regular” java.util.logging you can set additional handlers in logging.properties as well as the various setttings like java.util.logging.SocketHandler.port for setting the port (which is required). From what I could see it looked like I could set these properties in the same console screen where I set the “custom” handler. I set them and saw that they were set in the domain.xml.
Problem is when the server boots I get BadPort (0) which means it isn’t picking up the property I set for the port (java.util.logging.SocketHandler.port=4446). This same behavior also happens in Sun ES 8.2.
I can not find any documentation anywhere as to how to set this stuff to get the port set. I also can’t find anything anywhere else for that matter. I posted in the Glassfish forum on java.net and nobody has responded. Is it possible that nobody trying to use Glassfish has successfully done this? Seems impossible to me. Going to search through the source to see if I can spot anything there but if anyone who reads this can help out please let me know.