title: Problems setting up LogEntries on App Engine
body: <p>I'm trying to <a href="https://logentries.com/doc/java/" rel="nofollow noreferrer">setup logentries</a> on App Engine backend <strong>Java</strong> on Android Studio</p>
  <p>I keep getting this error message whatever I did</p>
  <blockquote>
  <p>log4j:WARN No appenders could be found for logger (root).</p>
  <p>log4j:WARN Please initialize the log4j system properly.</p>
  <p>log4j:WARN See <a href="http://logging.apache.org/log4j/1.2/faq.html#noconfig" rel="nofollow noreferrer">http://logging.apache.org/log4j/1.2/faq.html#noconfig</a> for more info.</p>
  </blockquote>
  <p>Here's my file structure</p>
  <p><img src="https://i.stack.imgur.com/YT10H.png" alt="File structure in Android Studio" /></p>
  <p><strong>log4j.properties</strong></p>
  <pre><code>log4j.rootLogger=ALL,le
  log4j.appender.le=com.logentries.log4j.LogentriesAppender
  log4j.appender.le.layout=org.apache.log4j.PatternLayout
  log4j.appender.le.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss ZZZ} %-5p: %F:%L  %m
  log4j.appender.le.Token=HIDDEN
  log4j.appender.le.Debug=True
  log4j.appender.le.Ssl=False
  </code></pre>
  <p><strong>log4j.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!DOCTYPE log4j:configuration SYSTEM &quot;log4j.dtd&quot; &gt;
  &lt;log4j:configuration debug=&quot;true&quot;&gt;
      &lt;appender name=&quot;le&quot; class=&quot;com.logentries.log4j.LogentriesAppender&quot;&gt;
          &lt;param name=&quot;Token&quot; value=&quot;HIDDEN&quot;/&gt;
          &lt;param name=&quot;Ssl&quot; value=&quot;false&quot;/&gt;
          &lt;param name=&quot;Debug&quot; value=&quot;true&quot;/&gt;
          &lt;layout class=&quot;org.apache.log4j.PatternLayout&quot;&gt;
              &lt;param name=&quot;ConversionPattern&quot; value=&quot;%d{EEE MMM dd HH:mm:ss ZZZ yyyy}, (%F:%L) %-5p: %m&quot;/&gt;
          &lt;/layout&gt;
      &lt;/appender&gt;
      &lt;logger name=&quot;example&quot;&gt;
          &lt;level value=&quot;debug&quot;/&gt;
      &lt;/logger&gt;
      &lt;root&gt;
          &lt;priority value=&quot;debug&quot;&gt;&lt;/priority&gt;
          &lt;appender-ref ref=&quot;le&quot;/&gt;
      &lt;/root&gt;
  &lt;/log4j:configuration&gt;
  </code></pre>
  <p><strong>appengine-web.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;appengine-web-app xmlns=&quot;http://appengine.google.com/ns/1.0&quot;&gt;
      &lt;application&gt;HIDDEN/application&gt;
      &lt;version&gt;1&lt;/version&gt;
      &lt;threadsafe&gt;true&lt;/threadsafe&gt;
  
      &lt;system-properties&gt;
          &lt;property name=&quot;java.util.logging.config.file&quot; value=&quot;WEB-INF/classes/log4j.properties&quot;/&gt;
          &lt;property name=&quot;log4j.configuration&quot; value=&quot;WEB-INF/classes/log4j.properties&quot;/&gt;
          &lt;property name=&quot;gcm.api.key&quot; value=&quot;HIDDEN&quot;/&gt;
      &lt;/system-properties&gt;
  &lt;/appengine-web-app&gt;
  </code></pre>
  <hr />
  <p><strong>Update</strong></p>
  <p>I found a very helpful tip in this question <a href="https://stackoverflow.com/questions/2772466/where-to-place-log4j-xml">Where to place log4j.xml</a>, basically put -Dlog4j.debug in the Java VM arguments and run App Engine in debug mode. It told me exactly whether it found log4j.xml or not. After much trial and error, It found it when I put it under WEB-INF/classes, now I can see precisely the full stack trace of the error I am having</p>
  <pre><code>INFO: Dev App Server is now running
  log4j: Trying to find [log4j.xml] using context classloader com.google.appengine.tools.development.IsolatedAppClassLoader@560cbf1a.
  log4j: Using URL [file:/C:/_Folder/_Code/AppNameHidden/backend/build/exploded-app/WEB-INF/classes/log4j.xml] for automatic log4j configuration.
  log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator
  log4j: System property is :null
  log4j: Standard DocumentBuilderFactory search succeded.
  log4j: DocumentBuilderFactory is: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
  log4j: debug attribute= &quot;true&quot;.
  log4j: reset attribute= &quot;false&quot;.
  log4j: Threshold =&quot;null&quot;.
  log4j: Retreiving an instance of org.apache.log4j.Logger.
  log4j: Setting [example] additivity to [true].
  log4j: Level value for example is  [debug].
  log4j: example level set to DEBUG
  log4j: Level value for root is  [debug].
  log4j: root level set to DEBUG
  log4j: Class name: [com.logentries.log4j.LogentriesAppender]
  log4j:ERROR Could not create an Appender. Reported error follows.
  java.security.AccessControlException: access denied (&quot;java.lang.RuntimePermission&quot; &quot;modifyThreadGroup&quot;)
      at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
      at java.security.AccessController.checkPermission(AccessController.java:884)
      at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
      at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:429)
      at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkAccess(DevAppServerFactory.java:454)
      at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
      at java.lang.Thread.init(Thread.java:391)
      at java.lang.Thread.init(Thread.java:349)
      at java.lang.Thread.&lt;init&gt;(Thread.java:508)
      at com.logentries.net.AsyncLogger$SocketAppender.&lt;init&gt;(AsyncLogger.java:496)
      at com.logentries.net.AsyncLogger.&lt;init&gt;(AsyncLogger.java:336)
      at com.logentries.net.AsyncLogger.&lt;init&gt;(AsyncLogger.java:343)
      at com.logentries.log4j.LogentriesAppender.&lt;init&gt;(LogentriesAppender.java:24)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
      at java.lang.Class.newInstance(Class.java:438)
      at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:247)
      at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176)
      at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191)
      at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:523)
      at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:492)
      at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:1006)
      at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:872)
      at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:778)
      at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
      at org.apache.log4j.LogManager.&lt;clinit&gt;(LogManager.java:127)
      at org.apache.log4j.Logger.getLogger(Logger.java:104)
      at hello.edu.appnamehidden.backend.RegistrationEndpoint.&lt;clinit&gt;(RegistrationEndpoint.java:36)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:344)
      at com.google.api.server.spi.ServletInitializationParameters.getClassForName(ServletInitializationParameters.java:82)
      at com.google.api.server.spi.ServletInitializationParameters.fromServletConfig(ServletInitializationParameters.java:51)
      at com.google.api.server.spi.SystemServiceServlet.init(SystemServiceServlet.java:102)
      at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
      at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
      at com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:59)
      at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:49)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
      at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
      at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
      at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:491)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:326)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
      at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
  log4j: Appender named [le] not found.
  Dec 31, 2014 1:50:36 AM com.google.api.server.spi.SystemServiceServlet init
  INFO: SPI restricted: true
  log4j: Finalizing appender named [null].
  </code></pre>
  <hr />
  <p><strong>Working workaround solution</strong></p>
  <p>Thanks to @MarkLC help I was able to get LogEntries working on the local machine, check the answer and comments <a href="https://stackoverflow.com/a/27688486/546439">https://stackoverflow.com/a/27688486/546439</a>, however, this never worked on the deployed App Engine.</p>
  <p>I had to resort to using this gist <a href="https://gist.github.com/anlcan/9348751" rel="nofollow noreferrer">https://gist.github.com/anlcan/9348751</a> and modifying it a little bit, it worked perfectly with App Engine when deployed.</p>
  <p>Here's my code</p>
  <pre><code>public class LogEntriesHelper
  {
      private static Socket socket = null;
      private static Lock lock = new ReentrantLock();
      private static Condition condition = lock.newCondition();
  
      private static final String LOG_TOKEN = &quot;HIDDEN&quot;;
  
      public static void log(String message)
      {
          try
          {
              if (socket == null || !socket.isConnected())
              {
                  if (lock.tryLock())
                  {
                      socket = new Socket(&quot;data.logentries.com&quot;, 10000);
                      condition.signalAll();
                      lock.unlock();
                  }
                  else
                  {
                      condition.await();
                  }
              }
  
              Writer out = new OutputStreamWriter(socket.getOutputStream(), &quot;UTF-8&quot;);
              socket.setSoTimeout(10000);
              out.write(LOG_TOKEN);
              out.write(&quot; &quot;);
              out.write(message);
              out.write(&quot;\r\n&quot;);
              out.flush();
          }
          catch (UnknownHostException e)
          {
              e.printStackTrace();
          }
          catch (IOException e)
          {
              e.printStackTrace();
          }
          catch (InterruptedException e)
          {
              e.printStackTrace();
          }
      }
  }
  </code></pre>