I am trying to add a custom log handler to my java application. I have implemented a InnerLogger class that extends java.util.Logging.Handler class. And in my logging.properties declared as a handler:
handlers:com.mycompany.util.InnerLogger
But when I launch the development sever, I got the following error:
Can't load log handler "com.mycompany.util.InnerLogger"
java.lang.ClassNotFoundException: com.mycompany.util.InnerLogger
I can add my custom handler to loggers one by one ,but I just wondering is there a way to add it to all loggers.
Thanks
I was able to add a Handler
to the root Logger
when my application initializes. You can put this code in a warmup task or servlet filter.
private static Logger LOG;
...
LOG = Logger.getLogger("");
LOG.addHandler(myCustomHandler);
Its not as graceful as using logging.properties, but it is an adequate workaround when running on GAE.
It might not the solution you were looking for, but have you considered using Simple Logging Facade for Java (SLF4J) in your application instead of using directly JUL?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With