...
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.
- If you want to just change 5% of the logging settings, why take control over the other 95% as well.
- 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
...
Here is that file's location in svn as well as all of the previous versions. Future versions will follow the same pattern.
- http://svn.apache.org/repos/asf/openejb/tags/openejb-3.1.1/container/openejb-core/src/main/resources/embedded.logging.properties
- http://svn.apache.org/repos/asf/openejb/tags/openejb-3.1/container/openejb-core/src/main/resources/embedded.logging.properties
- http://svn.apache.org/repos/asf/openejb/tags/openejb-3.0/container/openejb-core/src/main/resources/embedded.logging.properties
- http://svn.apache.org/repos/asf/openejb/tags/openejb-3.0-beta-2/container/openejb-core/src/main/resources/embedded.logging.properties
- http://svn.apache.org/repos/asf/openejb/tags/openejb-3.0-beta-1/container/openejb-core/src/main/resources/embedded.logging.properties