eclipse - Log4j2 in Eclipse and Maven - need to have different config files - answerstu - answerstu

Log4j2 in Eclipse and Maven - need to have different config files

I am using Eclipse and m2e on my workstation.

Sometimes I run my unit tests individually with the built-in Eclipse JUnit functionality to display the results in the JUnit view.

At other times before checking in code, I run the whole test suite and integration tests using the Maven test goal.

However when I forget to change my log4j2 configuration to set the minimum log level to DEBUG, then the Maven process kills Eclipse and I need to restart.

I mostly set the log level to TRACE when I am running individual unit tests.

My log4j2 config file is in my src/test/resources directory.

I also have log4j2 set up in-container to read a config file on the file system.

Can I configure my Maven goal in the Eclipse Run dialog to use a different log4j2 file?

1 Answer

  1. Alva- Reply


    Turned out to be quite simple.

    Create a new config file src/test/resources/log4j2-maven.xml

    Configure the surefire test runner in the pom.xml:


Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>