I'm running into the same issue (I'm using logback 0.9.21).

I tried to configure Logback manually using the JoranConfigurator.

Well, I started extending the JoranConfigurator trying to avoid the
call to the method ContextUtil.addHostNameAsProperty() in the
ConfigurationAction class that is the one causing the issue but it
looked I needed to extend a few classes and started to look messy.

At the end I took a different approach. Just created the ContextUtil
class in my webapp project in the same package as the original one so
mine would be picked instead of the other.

This is the code I put for that class ... (basically removing the use
of java.net.InetAddress class)

package ch.qos.logback.core.util;

import ch.qos.logback.core.Context;
import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.spi.ContextAwareBase;

public class ContextUtil extends ContextAwareBase {

        public ContextUtil(Context context) {
                setContext(context);
        }

        /**
         * Add the local host's name as a property
         */
        public void addHostNameAsProperty() {
                context.putProperty(CoreConstants.HOSTNAME_KEY, "yourhostname");
        }
}

Hope it helps.


On May 21, 3:28 am, Sean <seanhor...@gmail.com> wrote:
> I've posted the same question over on the logback forum but I wanted
> to check here to see who is using SLF4J/logback with GAE:
>
> http://old.nabble.com/Google-App-Engine-and-java.net.InetAddress-ts28...
>
> Question is posted here again:
>
> I'm trying to hook up slf4j/logback into a Google App Engine project
> but it looks like I'm running into a problem with a class that GAE
> blocks, namely java.net.InetAddress.  I'm using the latest: slf4j
> 1.6.0 and logback 0.9.21, tied into v1.3.3.1 of the AppEngine SDK and
> here is my java version:
>
> * java version "1.6.0_18"
> * OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
> * OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
>
> If I don't include a logback.xml, my gae dev server starts up properly
> and I see my log messages printed to the console.
>
> The place in *my* code where the failure happens is in the very first
> call to grab the logger, in
> com.cosanta.eventflow.control.EventServletContextListener:43, which is
> just:
>
>         private org.slf4j.Logger logger =
> org.slf4j.LoggerFactory.getLogger(this.getClass().getName());
>
> I took the logback.xml right out of the examples: logback-examples/src/
> main/java/chapters/configuration/sample0.xml:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <configuration>
>
>   <appender name="STDOUT"
>     class="ch.qos.logback.core.ConsoleAppender">
>     <!-- encoders are assigned by default the type
>          ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
>     <encoder>
>       <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg
> %n</pattern>
>     </encoder>
>   </appender>
>
>   <root level="debug">
>     <appender-ref ref="STDOUT" />
>   </root>
> </configuration>
>
> When I try to start the GAE dev server from my eclipse workspace, I
> get the following printed to the console:
>
> May 21, 2010 1:25:05 AM
> com.google.apphosting.utils.config.AbstractConfigXmlReader
> readConfigXml
> INFO: Successfully processed /home/sean/Dropbox/dev/workspace/
> EventFlow/war/WEB-INF/web.xml
> 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.addHostNameAsProperty(ContextUtil.java :
> 34)
>         at
> ch.qos.logback.classic.joran.action.ConfigurationAction.begin(Configuration 
> Action.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(GenericConfigurat 
> or.java:
> 126)
>         at
> ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurat 
> or.java:
> 93)
>         at
> ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurat 
> or.java:
> 52)
>         at
> ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextI 
> nitializer.java:
> 60)
>         at
> ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitialize 
> r.java:
> 121)
>         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
> com.cosanta.eventflow.control.EventServletContextListener.<init>(EventServl 
> etContextListener.java:
> 43)
>         at
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>         at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcce 
> ssorImpl.java:
> 57)
>         at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstru 
> ctorAccessorImpl.java:
> 45)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:
> 532)
>         at java.lang.Class.newInstance0(Class.java:372)
>         at java.lang.Class.newInstance(Class.java:325)
>         at
> org.mortbay.jetty.webapp.WebXmlConfiguration.newListenerInstance(WebXmlConf 
> iguration.java:
> 650)
>         at
> org.mortbay.jetty.webapp.WebXmlConfiguration.initListener(WebXmlConfigurati 
> on.java:
> 631)
>         at
> org.mortbay.jetty.webapp.WebXmlConfiguration.initWebXmlElement(WebXmlConfig 
> uration.java:
> 368)
>         at
> org.mortbay.jetty.webapp.WebXmlConfiguration.initialize(WebXmlConfiguration 
> .java:
> 289)
>         at
> org.mortbay.jetty.webapp.WebXmlConfiguration.configure(WebXmlConfiguration. 
> java:
> 222)
>         at
> org.mortbay.jetty.webapp.WebXmlConfiguration.configureWebApp(WebXmlConfigur 
> ation.java:
> 180)
>         at
> org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:
> 1247)
>         at
> org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:
> 517)
>         at
> org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:
> 467)
>         at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
> 50)
>         at
> org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:
> 130)
>         at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
> 50)
>         at
> org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:
> 130)
>         at org.mortbay.jetty.Server.doStart(Server.java:224)
>         at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
> 50)
>         at
> com.google.appengine.tools.development.JettyContainerService.startContainer 
> (JettyContainerService.java:
> 185)
>         at
> com.google.appengine.tools.development.AbstractContainerService.startup(Abs 
> tractContainerService.java:
> 146)
>         at
> com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerI 
> mpl.java:
> 219)
>         at com.google.appengine.tools.development.DevAppServerMain
> $StartAction.apply(DevAppServerMain.java:162)
>         at com.google.appengine.tools.util.Parser
> $ParseResult.applyArgs(Parser.java:48)
>         at
> com.google.appengine.tools.development.DevAppServerMain.<init>(DevAppServer 
> Main.java:
> 113)
>         at
> com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMa 
> in.java:
> 89)
> 01:25:06,971 |-INFO in ch.qos.logback.classic.LoggerContext[default] -
> Found resource [WEB-INF/logback.xml] at [file:/home/sean/Dropbox/dev/
> workspace/EventFlow/war/WEB-INF/logback.xml]
> 01:25:07,598 |-INFO in
> ch.qos.logback.classic.joran.action.ConfigurationAction - debug
> attribute not set
>
> The server is running athttp://localhost:8888/
>
> So as you can see, the server starts fine.  It has no problem handling
> requests etc but there is no further logging displayed.
>
> The logback code that causes GAE to scream is the placement of the
> hostname onto the context in ContextUtils:34:
>
>       InetAddress localhost = InetAddress.getLocalHost();
>       context.putProperty(CoreConstants.HOSTNAME_KEY,
> localhost.getHostName());
>
> Has anyone seen the same problem?
>
> Is there something I'm misconfiguring?
>
> If not, is there any way to work around this?
>
> Thanks for your help.
>
> Sean
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine for Java" group.
> To post to this group, send email to google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-appengine-java+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/google-appengine-java?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to