我有一个在Google App Engine(GAE)v1.8.2上运行的应用程序。我一直在使用java.util.logging。我的类有记录器定义为:关闭Google App Engine应用程序中的控制台日志记录
private static final Logger logger = Logger.getLogger(MyClass.class.getName());
我的AppEngine-web.xml中有这些行:
<!-- Configure java.util.logging -->
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
的logging.properties文件包含这些行:
# 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
但是,我还是继续看INFO从我的代码登录在浏览器控制台中。如何关闭完全注销的控制台?
更新:
# 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
感谢:我的AppEngine上的Java-SDK-1.8.2 /配置/ SDK/logging.properties文件的内容。
我仍然看到SimpleFormatter的输出。我的logging.properties文件位于WEB-INF下。我如何检查#2,#3和#4?谢谢你的帮助。 – DFB
@DFB#2 System.getSecurityManager()。checkPermission。 #3&#4使用LogManager获取所有记录器名称,然后按名称询问每个记录器。 – jmehrens
我应该检查哪个权限?我无法在GAE中使用LogManager。它说GAE的Java运行时环境不支持LogManager。在我的代码中,我只有信息和警告日志(logger.info(“something”)和logger.warn(“something”))。它似乎没有使用我的logging.properties。再次感谢您的帮助。 – DFB