如何在Java中设置Appengine DataStore的loglevel

时间:2012-04-17 15:11:54

标签: java google-app-engine datanucleus java.util.logging

我的Java AppEngine项目中有一个logging.properties文件(使用java.util.logging),如下所示:

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

# tighten logging on the DataNucleus Categories
DataNucleus.JDO.level=WARN 
# - All messages general to JDO
DataNucleus.JPA.level=WARN 
#  - All messages general to JPA
DataNucleus.Persistence.level=WARN 
#  - All messages relating to the persistence process
DataNucleus.Query.level=WARN 
#  - All messages relating to queries
DataNucleus.Lifecycle.level=WARN 
#  - All messages relating to object lifecycle changes
DataNucleus.Cache.level=WARN 
#  - All messages relating to the DataNucleus Cache
DataNucleus.ClassLoading.level=WARN 
#  - All exceptions relating to class loading issues
DataNucleus.MetaData.level=WARN 
#  - All messages relating to MetaData
DataNucleus.Management.level=WARN 
#  - All messages relating to Management
DataNucleus.General.level=WARN 
#  - All general operational messages
DataNucleus.Connection.level=WARN 
#  - All messages relating to Connections.
DataNucleus.JCA.level=WARN 
#  - All messages relating to Connector JCA.
DataNucleus.Transaction.level=WARN 
#  - All messages relating to transactions
DataNucleus.Plugin.level=WARN 
#  - All messages relating to DataNucleus plug-ins
DataNucleus.ValueGeneration.level=WARN 
#  - All messages relating to value generation
DataNucleus.Datastore.level=WARN 
#  - All general datastore messages
DataNucleus.Datastore.Schema.level=WARN 
#  - All schema related datastore log messages
DataNucleus.Datastore.Persist.level=WARN 
#  - All datastore persistence messages
DataNucleus.Datastore.Retrieve.level=WARN 
#  - All datastore retrieval messages
DataNucleus.Datastore.Native.level=WARN 
#  - Log of all 'native' statements sent to the datastore
DataNucleus.Enhancer.level=WARN 
#  - All messages from the DataNucleus Enhancer.
DataNucleus.SchemaTool.level=WARN 
#  - All messages from DataNucleus SchemaTool
DataNucleus.IDE.level=WARN 
#  - Messages from the DataNucleus IDE.

可悲的是,现在我收到日志消息,例如:

2012-04-17 16:13:45.112
org.datanucleus.plugin.NonManagedPluginRegistry resolveConstraints: Bundle "org.datanucleus.jpa" has an optional dependency to "org.datanucleus.enhancer" but it cannot be resolved

I 2012-04-17 16:13:45.115    
org.datanucleus.plugin.NonManagedPluginRegistry resolveConstraints: Bundle "org.datanucleus" has an optional dependency to "org.eclipse.equinox.registry" but it cannot be resolved

I 2012-04-17 16:13:45.719
org.datanucleus.PersistenceConfiguration setProperty: Property datanucleus.rdbms.sql.allowAllSQLStatements unknown - will be ignored

I 2012-04-17 16:13:47.806
org.datanucleus.store.appengine.MetaDataValidator validate: Performing appengine-specific metadata validation for in.animeshpathak.nazdeeq.models.Note

有人可以告诉我如何正确配置我的logging.properties文件吗?我需要INFO的常规日志级别,以便此时查看来自我的代码的调试消息,但是希望将所有DataNucleus日志级别设置为WARN

感谢。

1 个答案:

答案 0 :(得分:6)

实际上,如果您想要查看代码中的调试消息,则需要FINEST级别,而不是INFO

尝试用以下内容替换logging.properties:

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

# Set the default logging level for ORM, specifically, to WARNING
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

根据DataNucleus的建议,这更为简洁:

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

# Set the default logging level for ORM, specifically, to WARNING
DataNucleus.level=WARNING