user1795667
user1795667

Reputation: 423

berkeley DB on GAE

I'm trying to use Berkely DB on GAE and everything worked fine except the logging. Here is the code snippet

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);

As can be seen I have disabled logging and my logging.properties file on GAE is

.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

i followed all the pointers given by others from stackoverflow but still I'm getting

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)

Any pointers on how to disabled logging from Berkley DB would be highly appreciated!

Upvotes: 0

Views: 87

Answers (1)

jmehrens
jmehrens

Reputation: 11045

Looks like com.sleepycat.je.utilint.LoggerUtils.getLogger method is always trying to install handlers on the root logger if they are not present. Specifically it is trying to install:

  1. java.util.logging.ConsoleHandler
  2. com.sleepycat.je.utilint.ConsoleRedirectHandler
  3. com.sleepycat.je.utilint.FileRedirectHandler
  4. com.sleepycat.je.utilint.ConfiguredRedirectHandler

Changing the logging configuration won't prevent the code from trying to do this.

It does appear that the com.sleepycat.je.utilint.LoggerUtils should be patched to deal with SecurityException thrown by addHandlers and NoClassDefFoundError for classes that extend restricted classes.

Upvotes: 1

Related Questions