Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-99

Can't use logback on GAE SDK 1.3.7 when configured with logback.xml

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      GAE/J 1.3.7

      Description

      Trying to initialize logback with custom configuration file (logback.xml) running on GAE platform throws the following exception

      Failed to instantiate [ch.qos.logback.classic.LoggerContext]
      Reported exception:
      java.lang.NoClassDefFoundError: java.net.InetAddress 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 ch.qos.logback.core.util.ContextUtil.getLocalHostName(ContextUtil.java:30)
      at ch.qos.logback.core.util.ContextUtil.addHostNameAsProperty(ContextUtil.java:39)
      at ch.qos.logback.classic.joran.action.ConfigurationAction.begin(ConfigurationAction.java:47)
      at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:273)
      at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:145)
      at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:127)
      at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:40)
      at ch.qos.logback.core.joran.spi.Interpreter.play(Interpreter.java:332)
      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:126)
      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:93)
      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:52)
      at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:77)
      at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
      at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
      at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
      at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
      at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
      at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:268)
      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:241)
      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:254)
      ......

      This happens because ch.qos.logback.core.util.ContextUtil.java contains are reference to a java.net.InetAddress which is a restricted class on Google AppEngine Platform SDK 1.3.7:

      static String getLocalHostName() throws UnknownHostException

      { InetAddress localhost = InetAddress.getLocalHost(); return localhost.getHostName(); }

      I should note that BasicConfigurator is working and is able to configure the logback subsystem.

      A couple of resolutions I can think of:

      1. Don't export this parameter by default, instead let the user choose if to define it or not in the logback.xml configuration file.
      2. Create a "GAEConfigurator" which will use default for the limited GAE environment.
      2. Provide a custom build for GAE platform, where this parameter will be taken from http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/utils/SystemProperty.html#applicationId or not be defined at all.
      4. Provide some method to override / use a different implementation of ContextUtil, one which will be suitable for GAE.

        Attachments

          Activity

            People

            • Assignee:
              logback-dev Logback dev list
              Reporter:
              maxim.veksler Maxim Veksler
            • Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: