OpenEJB Logger configuration when running tests from TestNG in Intellij IDEA

alex440

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:

  1. 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.properties
    
  2. Provide 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:

  1. System.setProperty("log4j.category.OpenEJB","off");
  2. All convolutions of upper/lower case in the previous statement
  3. Setting Environment variables in IntelliJ Run/Debug configurations
  4. Putting the following file embedded.logging.properties to ../../../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.SimpleLayout
    
  5. Putting the same file with the name log4j.embedded.logging.properties to ../../../build/ejbhome

  6. Putting the same file with the name jndi.properties to ../../../build/ejbhome
  7. Putting these 3 files to the module dir/conf
  8. Setting IntelliJ classpath to the directory above with Project Structure -> Dependencies

Neither way has any effect on the line output.

Romain Manni-Bucau

OpenEJB uses JUL by default and therefore you just need to configure JUL as on any JVM setting java.util.logging.config.file on the JVM and using JUL syntax and not log4j one (by default log4j is not in the classpath).

Alternative is to add in app composer properties (@Configuration):

openejb.jul.forceReload=true
# custom handler impl
openejb.jul.consoleHandlerClazz = com.company.MyHandler
# then jul properties, see org.apache.openejb.util.JuliLogStreamFactory.OpenEJBLogManager for advanced usage

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

"No tests found for given includes" when running Gradle tests in IntelliJ IDEA

From Dev

"No tests found for given includes" when running Gradle tests in IntelliJ IDEA

From Dev

ActiveMQ in-memory broker not starting when tests running in IntelliJ IDEA

From Dev

ActiveMQ in-memory broker not starting when tests running in IntelliJ IDEA

From Dev

Running a certain TestNG test group with IntelliJ IDEA

From Dev

Running a certain TestNG test group with IntelliJ IDEA

From Dev

Running jest tests directly in Intellij Idea/WebStorm?

From Dev

When running tests from "sbt test" the classpath is different than when running from IDEA

From Dev

IntelliJ NoClassDefFoundError when running IntelliJ Tests

From Dev

Is it possible to run several TestNG suite files in one configuration in IntelliJ IDEA?

From Dev

Jenkins not running TestNG Tests

From Dev

Play framework 2 running unit tests in Intellij IDEA 13

From Dev

Play framework 2 running unit tests in Intellij IDEA 13

From Dev

BeforeGroups method is not executed when running testng tests by maven

From Dev

Eliminating the need for testng.xml when running Java unit tests in TestNG

From Dev

TestNG not running tests in testing suite

From Dev

Jenkins: Jenkins not running TestNG Tests

From Dev

Intellij complains about fork mode when running tests with code cover

From Dev

Empty benchmarks when running JMH samples in Intellij IDEA

From Dev

intellij idea 14 and gradle issues when running integTests

From Dev

Gradle daemon not reused when running in debug mode (in IntelliJ IDEA)

From Dev

java.lang.ClassNotFoundException when running in IntelliJ IDEA

From Dev

IntelliJ IDEA 13: Keyboard shortcuts to navigate stack trace after running tests?

From Dev

How to automate running tests before commit in Intellij Idea, without additional software?

From Dev

TestNG, running different tests depending on version of application

From Dev

Running tests in parallel using TestNG and gradle

From Dev

testng.xml is not running from pom.xml during executing selenium tests

From Dev

testng.xml is not running from pom.xml during executing selenium tests

From Dev

Running Unit and Integration Tests in IntelliJ

Related Related

  1. 1

    "No tests found for given includes" when running Gradle tests in IntelliJ IDEA

  2. 2

    "No tests found for given includes" when running Gradle tests in IntelliJ IDEA

  3. 3

    ActiveMQ in-memory broker not starting when tests running in IntelliJ IDEA

  4. 4

    ActiveMQ in-memory broker not starting when tests running in IntelliJ IDEA

  5. 5

    Running a certain TestNG test group with IntelliJ IDEA

  6. 6

    Running a certain TestNG test group with IntelliJ IDEA

  7. 7

    Running jest tests directly in Intellij Idea/WebStorm?

  8. 8

    When running tests from "sbt test" the classpath is different than when running from IDEA

  9. 9

    IntelliJ NoClassDefFoundError when running IntelliJ Tests

  10. 10

    Is it possible to run several TestNG suite files in one configuration in IntelliJ IDEA?

  11. 11

    Jenkins not running TestNG Tests

  12. 12

    Play framework 2 running unit tests in Intellij IDEA 13

  13. 13

    Play framework 2 running unit tests in Intellij IDEA 13

  14. 14

    BeforeGroups method is not executed when running testng tests by maven

  15. 15

    Eliminating the need for testng.xml when running Java unit tests in TestNG

  16. 16

    TestNG not running tests in testing suite

  17. 17

    Jenkins: Jenkins not running TestNG Tests

  18. 18

    Intellij complains about fork mode when running tests with code cover

  19. 19

    Empty benchmarks when running JMH samples in Intellij IDEA

  20. 20

    intellij idea 14 and gradle issues when running integTests

  21. 21

    Gradle daemon not reused when running in debug mode (in IntelliJ IDEA)

  22. 22

    java.lang.ClassNotFoundException when running in IntelliJ IDEA

  23. 23

    IntelliJ IDEA 13: Keyboard shortcuts to navigate stack trace after running tests?

  24. 24

    How to automate running tests before commit in Intellij Idea, without additional software?

  25. 25

    TestNG, running different tests depending on version of application

  26. 26

    Running tests in parallel using TestNG and gradle

  27. 27

    testng.xml is not running from pom.xml during executing selenium tests

  28. 28

    testng.xml is not running from pom.xml during executing selenium tests

  29. 29

    Running Unit and Integration Tests in IntelliJ

HotTag

Archive