How can I configure OpenEJB logging format? This is what what I see now in logs:
[...]
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.011 sec
Running com.XXX.FooTest
Apache OpenEJB 3.1.3 build: 20101015-05:42
http://openejb.apache.org/
INFO - openejb.home = /code/XXX
INFO - openejb.base = /code/XXX
INFO - Configuring Service(id=Default Security Serv...
[...]
I would like to disable INFO
messages, and change formatting of others. Changes in log4j.properties
have no effect.
If you don't mind using another logging framework, these links might be useful.
http://hwellmann.blogspot.fi/2012/11/logging-with-slf4j-and-logback-in.html
JUL to SLF4J Bridge
Don't use
openejb.logger.external=true
with this approach. See http://grepcode.com/file/repo1.maven.org/maven2/org.apache.openejb/openejb-core/3.0/org/apache/openejb/util/JuliLogStreamFactory.javaKeep in mind that the overriding ability you get with the OpenEJB logger works with system properties as well as InitialContext properties.
The
openejb.logger.external
property is really aimed at servers integrating OpenEJB, such as Geronimo, who are using different logging systems and need advanced control over logging. It is not designed for common use as with this option enabled and no other steps taken, you get no logging of any kind, not even ERROR, and no info on failed deployments. Even correct usage will still disable all options discussed below.If the desire is to get the logging configuration in or out of the test there are many ways to do it without losing any logging functionality OpenEJB provides.
Option 1: in code via InitialContext properties
In the test case itself via InitialContext properties
Option 2: a jndi.properties file
File must be in the classpath at any path that evaluates to "/jndi.properties", so not "/META-INF/jndi.properties"
In Maven this can be done by placing the file at
src/test/resources/jndi.properties
Here is a short video of the above option in action.
Note that finding and reading the jndi.properties file is a functionality of the java vm so if it doesn't work, it is more likely to be a configuration issue rather than a vm bug.
Option 3: Maven Surefire config
Option 4: any combination
Also note that all of the above techniques can be used at once, including any overrides you wish to put in individual test cases. The order of precedence is as follows:
Option 5: Request a feature
As always we are very happy to make things easier in any way we can. If you have a specific need or idea, we're happy to try and work it in or help you do it should you want to contribute.
This is what I did to make things work properly (in
pom.xml
):Works fine now. This is my
test/resources/jndi.properties
:This is
test/resources/log4j.properties
:Now I can fine-tune logging of OpenEJB during testing, thanks to David's support :)
According to Configuring Logging in Tests, you can override the default logging configuration:
InitialContext
creation time ~or~embedded.logging.properties
on the classpathThat's the recommended approach.
As an alternative, you can disable the entire default configuration and provide your own: