Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Alternatively, you can set "openejb.logger.external" to "true" as a system property (will not work as an InitialContext property). Then OpenEJB will not attempt to configure logging at all and you can configure logging with Log4j directly using any of its APIs; xml, properties, or code.

There are a couple good reasons for not replacing the embedded.logging.properties file.

  1. If you want to just change 5% of the logging settings, why take control over the other 95% as well.
  2. We do occasionally add new logging categories. If you are not replacing the embedded.logging.properties you will pick these up automatically when you upgrade.

Overriding (recommended)

As mentioned in Embedded Configuration much can be done with simple overriding. The default embedded.logging.properties is quite good and there is really no need to replace it completely if all you want to do is tweak a few values.

You can also put logging tweaks right in your InitialContext properties like so:

Code Block

Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");

p.put("log4j.rootLogger", "fatal,C");
p.put("log4j.category.OpenEJB", "warn");
p.put("log4j.category.OpenEJB.options", "info");
p.put("log4j.category.OpenEJB.server", "info");
p.put("log4j.category.OpenEJB.startup", "info");
p.put("log4j.category.OpenEJB.startup.service", "warn");
p.put("log4j.category.OpenEJB.startup.config", "info");
p.put("log4j.category.OpenEJB.hsql", "info");
p.put("log4j.category.CORBA-Adapter", "info");
p.put("log4j.category.Transaction", "warn");
p.put("log4j.category.org.apache.activemq", "error");
p.put("log4j.category.org.apache.geronimo", "error");
p.put("log4j.category.openjpa", "error");
p.put("log4j.appender.C", "org.apache.log4j.ConsoleAppender");
p.put("log4j.appender.C.layout", "org.apache.log4j.SimpleLayout");

Context context = new InitialContext(p);

Essentially, everything starting with "log4j." gets applied as overrides on top of the embedded.logging.properties we find in the classpath. This makes it possible to easily tweak the log levels while debugging a particular test.

Note, that InitialContext properties can also be supplied in a jndi.properties file in the classpath or via system properties. The overriding order is as follows: 1 = highest, 4 = lowest.

...

By default there are no logging settings in 1-3, so #4 is the only source of logging information.

There are a couple good reasons for not replacing the embedded.logging.properties file.

...

.

Default embedded.logging.properties contents

...