我正在尝试在GAE上使用Berkely DB,除了日志记录之外,其他一切都正常。这是代码片段
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(allowCreateNew);
envConfig.setConfigParam(EnvironmentConfig.FILE_LOGGING_LEVEL, "OFF");
envConfig.setConfigParam(EnvironmentConfig.CONSOLE_LOGGING_LEVEL, "OFF");
envConfig.setLoggingHandler(null);
envConfig.setReadOnly(isReadOnly);
envConfig.setTransactional(false);
if (cacheSize != null)
envConfig.setCacheSize(cacheSize);
env = new Environment(dbPath, envConfig);
可以看出,我已禁用日志记录,而GAE上的logging.properties文件是
.level = WARNING
handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=OFF
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
# 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
java.sql.level=WARNING
我遵循了其他人从stackoverflow给出的所有指针,但是我仍然在
java.lang.NoClassDefFoundError: java.util.logging.ConsoleHandler is a restricted class. Please see the Google App Engine developer's guide for more details.
at
com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
at com.sleepycat.je.utilint.ConsoleRedirectHandler.<init>(ConsoleRedirectHandler.java:26)
at com.sleepycat.je.utilint.LoggerUtils.getLogger(LoggerUtils.java:198)
at com.sleepycat.je.dbi.StartupTracker.<init>(StartupTracker.java:151)
at com.sleepycat.je.dbi.EnvironmentImpl.<init>(EnvironmentImpl.java:437)
at com.sleepycat.je.dbi.EnvironmentImpl.<init>(EnvironmentImpl.java:410)
at com.sleepycat.je.dbi.DbEnvPool.getEnvironment(DbEnvPool.java:178)
at com.sleepycat.je.Environment.makeEnvironmentImpl(Environment.java:251)
at com.sleepycat.je.Environment.<init>(Environment.java:232)
at com.sleepycat.je.Environment.<init>(Environment.java:176)
任何有关如何从Berkley DB禁用日志记录的指针将不胜感激!
最佳答案
看起来com.sleepycat.je.utilint.LoggerUtils .getLogger方法始终尝试在根记录器上安装处理程序(如果不存在)。具体来说,它正在尝试安装:
java.util.logging.ConsoleHandler
com.sleepycat.je.utilint.ConsoleRedirectHandler
com.sleepycat.je.utilint.FileRedirectHandler
com.sleepycat.je.utilint.ConfiguredRedirectHandler
更改日志记录配置不会阻止代码尝试执行此操作。
似乎确实应该对com.sleepycat.je.utilint.LoggerUtils进行修补,以处理addHandlers和NoClassDefFoundError引发的SecurityException,以扩展受限制的类。