OpenEJB and TomEE allows you to switch logging framework pretty easily if you prefer log4j, slf4J or any other library for that purpose.
Note: all our stack doesn’t yet support it (I think of apache bval and apache webbeans which has only a hook on the snapshot today). But cxf, openjpa, openejb and tomee can use this feature.
How to switch?
Simply set the system property (once again conf/system.properties or properties given to EJBContainer in standalone are also fine):
The supported value are:
- jul or juli for Java Util Logging (default)
- slf4j (default implementation is slf4j-jdk14 so JULI too)
- log4j ( you’ll need to add log4J jar to TomEE or OpenEJB)
- Pax (in OSGi but well, this one is not really useful every day)
- Your unique setting is a qualified name.
Typically, to use log4j you’ll have to add the log4j jar. Then, add to your JVM the following :
Note : for log4j, you better replace slf4j-jdk14 with slf4j-log4j12. Finally, adding slf4j jul bridge and configuring the right handler make all logs go to log4j at ones (but you need to add this jar too).
Your own logger?
You need to implement two classes: a logger factory and a logger. The factory is org.apache.openejb.util.LogStreamFactory and the logger is org.apache.openejb.util.LogStream.
It uses a LogCategory which is just a name but several onces are defined by default.
If you need a custom logger, which is not company specific, please send openejb mailing list an e-mail to let us know, we may be able to integrate it!