Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
801 views
in Technique[技术] by (71.8m points)

junit - Logging level under maven surefire

I'm unable to adjust java logging's logging level. I'm using maven surefire (mvn test), and trying to adjust from the default INFO to e.g. FINEST.

I have logging.properties file under src/test/resources/logging.properties

after compile, i see under target/test-classes, i see a logging.properties file with the intended config:

java.util.logging.ConsoleHandler.level=FINEST

javax.enterprise.system.container.ejb.level=FINE

...

however the console output from glassfish only have INFO / SEVERE level messages.

Where did I go wrong? or is this another pain in the butt thing with maven?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I tried setting java.util.logging.config.file in the MAVEN_OPTS environment variable, which does not work but finally got it working by putting that system property in the pom.xml (and of course creating an appropriate logging.properties in src/test/resources):

    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
           <systemProperties>
             <property> 
               <name>java.util.logging.config.file</name>
               <value>src/test/resources/logging.properties</value>
             </property>
           </systemProperties>
        </configuration>
      </plugin>
    </plugins>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...