0
votes

I have an application running on the Google App Engine (GAE) v1.8.2. I have been using java.util.logging. My classes have the logger defined as:

private static final Logger logger = Logger.getLogger(MyClass.class.getName());

My appengine-web.xml has these lines:

  <!-- Configure java.util.logging -->
  <system-properties>
    <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
  </system-properties>

The logging.properties files contains these lines:

# 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>
# WARNING , INFO, SEVERE, OFF
handlers=java.util.logging.ConsoleHandler
# Set the default logging level for all loggers to WARNING
.level = OFF
java.util.logging.ConsoleHandler.level=OFF
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

However, I still continue to see the INFO logging from my code in the browser console. How do I turn off the console logging off completely?

Update: Contents of my appengine-java-sdk-1.8.2/config/sdk/logging.properties file:

# Logging configuration file for Google App Engine tools.

# Specify the handlers to create in the root logger
# (all loggers are children of the root logger)
# The following creates the console handler
handlers = java.util.logging.ConsoleHandler

# Set the default logging level for the root logger
.level = INFO

# Set the default logging level for the datanucleus loggers
DataNucleus.JDO.level=WARNING
DataNucleus.Persistence.level=WARNING
DataNucleus.Cache.level=WARNING
DataNucleus.MetaData.level=WARNING
DataNucleus.General.level=WARNING
DataNucleus.Utility.level=WARNING
DataNucleus.Transaction.level=WARNING
DataNucleus.Datastore.level=WARNING
DataNucleus.ClassLoading.level=WARNING
DataNucleus.Plugin.level=WARNING
DataNucleus.ValueGeneration.level=WARNING
DataNucleus.Enhancer.level=WARNING
DataNucleus.SchemaTool.level=WARNING

# FinalizableReferenceQueue tries to spin up a thread and fails.  This
# is inconsequential, so don't scare the user.
com.google.common.base.FinalizableReferenceQueue.level=WARNING
com.google.appengine.repackaged.com.google.common.base.FinalizableReferenceQueue.level=WARNING

# We assume that people will generally want to see this message, even
# if they override the root level to WARNING.  If they really want to
# turn it off, they can always override this level as well.
com.google.appengine.tools.development.DevAppServerImpl.level=INFO

Thanks.

1

1 Answers

0
votes

You should confirm that the LogManager is using your logging.properties. An easy way to test that would be to change the ConsoleHandler formatter from java.util.logging.SimpleFormatter to java.util.logging.XMLFormatter then see if your output is xml. If it is xml then you could try commenting out the handlers= line. If the output is still from the SimpleFormatter then:

  1. Check the path to the logging.properties.
  2. Ensure a SecurityManager is not preventing changes to logging.
  3. Write code to walk all of the loggers and output the classname of all attached handlers. Then update your logging.properties to disable any other handlers that might be writing to the console.
  4. Write code to walk all of the loggers and disable and all console handlers.
  5. System.out.close(); System.err.close();
  6. new FileOutputStream(FileDescriptor.out).close(); new FileOutputStream(FileDescriptor.err).close();