I have a problem configuring the logs output when running tests from IntelliJ.
Every change I make does not seem to have an effect.
I run the test using @Module annotation via ApplicationComposer.
@Listeners(ApplicationComposerListener.class)
public class TestLogs {
private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB, TestLogs.class);
@Module
@Classes(cdi=true,value = {
})
public EjbModule ejbModule() throws Exception {
EjbModule ejbModule = new EjbModule(new EjbJar());
System.setProperty("openejb.home", "../../../build/ejbhome");
System.setProperty("openejb.deployments.classpath.include",".*(my_app).*");
System.setProperty("ejb.jndi.name.app", getClass().getSimpleName());
System.setProperty("ejb.jndi.name.module", ejbModule.getModuleId());
System.setProperty("log4j.category.OpenEJB","off");
return ejbModule;
}
@Test
public void testLog_LoggingIsOff() {
LOGGER.info("*********************************************************");
}
}
When I run the test, the log line with wildcards gets printed in the console, though I set up configuration that should have turned the logs off for OpenEJB category.
EDIT
The solution that did work:
Provide the following settings In the VM options on the JDK settings tab in the Debug/Run configuration (and not in the @JvmParams annotation, as it is loaded after the JuliLogStreamFactory)
-Djava.util.logging.config.file=path\to\\file.logging.propertiesProvide the relevant file handlers in the config file
handlers = org.apache.openejb.log.FileHandler, java.util.logging.ConsoleHandler .level = INFO org.apache.openejb.log.FileHandler.level = FINE org.apache.openejb.log.FileHandler.directory = logs org.apache.openejb.log.FileHandler.prefix = my_tests_log. org.apache.openejb.log.FileHandler.formatter = java.util.logging.SimpleFormatter java.util.logging.ConsoleHandler.level = SEVERE java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter java.util.logging.SimpleFormatter.format = %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$s [location: %2$s] %5$s%6$s%n
Not working stuff:
Ways I tried to turn off the logging:
System.setProperty("log4j.category.OpenEJB","off");- All convolutions of upper/lower case in the previous statement
- Setting Environment variables in IntelliJ
Run/Debug configurations Putting the following file
embedded.logging.propertiesto../../../build/ejbhome:log4j.rootLogger = fatal,C log4j.category.OpenEJB = off log4j.category.OpenEJB.server = info log4j.category.OpenEJB.startup = info log4j.category.OpenEJB.startup.service = warn log4j.category.OpenEJB.startup.config = info log4j.category.OpenEJB.hsql = info log4j.category.CORBA-Adapter = info log4j.category.Transaction = warn log4j.category.org.apache.activemq = error log4j.category.org.apache.geronimo = error log4j.category.openjpa = error log4j.appender.C = org.apache.log4j.ConsoleAppender log4j.appender.C.layout = org.apache.log4j.SimpleLayoutPutting the same file with the name
log4j.embedded.logging.propertiesto../../../build/ejbhome- Putting the same file with the name
jndi.propertiesto../../../build/ejbhome - Putting these 3 files to the module
dir/conf - Setting IntelliJ classpath to the directory above with
Project Structure->Dependencies
Neither way has any effect on the line output.