Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m2e integration with logging manager #1321

Open
nimo23 opened this issue Apr 18, 2024 · 1 comment
Open

m2e integration with logging manager #1321

nimo23 opened this issue Apr 18, 2024 · 1 comment

Comments

@nimo23
Copy link

nimo23 commented Apr 18, 2024

I have this in my pom.xml:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${v.plugin.surefire}</version>
    <configuration>
        <systemPropertyVariables>
            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
        <maven.home>${maven.home}</maven.home>
        </systemPropertyVariables>
    </configuration>
</plugin>

When running Junit tests of the entire project (mvn test), the logging within all test classes works as expected. Eclipse uses the systemPropertyVariables defined in the Surefire plugin.

However, when executing only one test case (e.g. a method annotated with @Test) and right-clicking on a test file ("Run as->Junit Test"), the logging doesn't work and I get this error the console:

ERROR: 
The LogManager accessed before the "java.util.logging.manager" system property was set to "org.jboss.logmanager.LogManager". 
Results may be unexpected.

To solve this issue, I need to

Right click on unit test file -> Run As -> Run Configuration -> JUnit -> Tab "Arguments"

and add the below line in "VM arguments"-section:

-Djava.util.logging.manager=org.jboss.logmanager.LogManager

With this workaround, logging for this file works. However, it is cumbersome to add this line to every Junit test class.

Would be nice if m2e took systemPropertyVariables into account when executing test files from the IDE (e.g. when right-clicking on a test file ("Run as->Junit Test")).

@Bananeweizen
Copy link
Contributor

workaround: add the system property to the JRE definition (of the JRE used in the test) in Preferences>Installed JREs instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants