OpenEJB, TomEE and log framework

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/ 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!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s