4

Before deploying my GAE app, I am running several hundreds of unit tests locally. I am using the LocalServiceTestHelper to use GAE services like memcache or the datastore. Setting up and tearing down the helper between tests creates a lot of log output.

How can I re-configure java.util.logging in order to avoid INFO messages caused by LocalServiceTestHelper entirely?

INFO: Local Datastore initialized: 
Type: Master/Slave
Storage: In-memory
Feb 08, 2013 7:01:52 PM com.google.appengine.api.taskqueue.dev.LocalTaskQueue init
INFO: LocalTaskQueue is initialized
Feb 08, 2013 7:01:52 PM com.google.appengine.api.taskqueue.dev.LocalTaskQueue init
INFO: Automatic task execution is disabled.
Feb 08, 2013 7:01:52 PM org.quartz.simpl.SimpleThreadPool initialize
INFO: Job execution threads will use class loader of thread: main
Feb 08, 2013 7:01:52 PM org.quartz.core.QuartzScheduler <init>
INFO: Quartz Scheduler v.null.null.null created.
Feb 08, 2013 7:01:52 PM org.quartz.simpl.RAMJobStore initialize
INFO: RAMJobStore initialized.
Feb 08, 2013 7:01:52 PM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
Feb 08, 2013 7:01:52 PM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler version: null.null.null
Feb 08, 2013 7:01:52 PM com.google.appengine.api.taskqueue.dev.LocalTaskQueue start_
INFO: Local task queue initialized with base url http://localhost:8080
Feb 08, 2013 7:01:52 PM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED shutting down.
Feb 08, 2013 7:01:52 PM org.quartz.core.QuartzScheduler standby
INFO: Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED paused.
Feb 08, 2013 7:01:52 PM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED shutdown complete.

EDIT:

I created the file src/test/resources/logging.properties. The file is copied to target/test-classes/ before the tests are executed. It has the following content:

com.google.appengine.api.taskqueue.dev.level=SEVERE
org.quartz.level=WARNING

But I am still seeing the same log output while running the tests.

4

2 回答 2

3

While the logging.properties file in src/test/resources/ was well-formed, the maven-surefire-plugin was not aware of its location. As described in another stackoverflow post, you have to set the java.util.logging.config.file system property when configuring the plugin. After applying this simple change everything works as expected.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.4.2</version>
  <configuration>
    <systemProperties>
      <property>
        <name>java.util.logging.config.file</name>
        <value>${project.build.directory}/test-classes/logging.properties</value>
      </property>
    </systemProperties>
   ...
于 2013-02-10T14:29:49.713 回答
0

Get a copy of logging.properties from your appengine-java-sdk/config/user/ folder and put it into your project's classpath, for instance src/test/resources folder if using maven, and start configuring your own settings from here:

# A default java.util.logging configuration.
# (All App Engine logging is through java.util.logging by default).
#
# To use this configuration, copy it into your application's WEB-INF
# folder and add the following to your appengine-web.xml:
# 
# <system-properties>
#   <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
# </system-properties>
#

# Set the default logging level for all loggers to WARNING
.level = WARNING

To configure log level for a particular package, using:

# Set logging level for particular package
com.google.appengine.api.taskqueue.dev.level = SEVERE
org.quartz.level = WARNING

For a complete configuration guide, check out lib/logging.properties in your JRE installation folder.

于 2013-02-08T23:35:50.350 回答