Log4j 2
  1. Log4j 2
  2. LOG4J2-703

Android: Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-rc2
    • Fix Version/s: 2.0, 2.0.1
    • Component/s: None
    • Labels:
      None
    • Environment:

      Android

      Description

      Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

      Am i missing something or is Log4J2 not working yet in an Android environment ?

      MyActivity.java
      import org.apache.logging.log4j.LogManager;
      import org.apache.logging.log4j.Logger;
      
      
      public class MyActivity extends Activity {
      
          static final Logger logger = LogManager.getLogger(MyActivity.class.getName());
      
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_my);
              logger.error("TEST ############################################");
          }
      
      07-08 10:40:23.401    1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
      07-08 10:40:23.441    1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
          Process: com.intl.log4j2xtest, PID: 1307
          java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                  at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                  at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                  at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                  at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                  at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                  at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                  at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                  at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                  at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                  at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                  at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                  at java.lang.Class.newInstanceImpl(Native Method)
                  at java.lang.Class.newInstance(Class.java:1208)
                  at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                  at android.app.ActivityThread.access$800(ActivityThread.java:135)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:136)
                  at android.app.ActivityThread.main(ActivityThread.java:5017)
                  at java.lang.reflect.Method.invokeNative(Native Method)
                  at java.lang.reflect.Method.invoke(Method.java:515)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                  at dalvik.system.NativeStart.main(Native Method)
      

      build.gradle file :

      apply plugin: 'com.android.application'
      
      android {
          compileSdkVersion 19
          buildToolsVersion "19.1.0"
      
          defaultConfig {
              applicationId "com.intl.log4j2xtest"
              minSdkVersion 19
              targetSdkVersion 19
              versionCode 1
              versionName "1.0"
          }
          buildTypes {
              release {
                  runProguard false
                  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
              }
          }
          packagingOptions {
              exclude 'META-INF/LICENSE'
              exclude 'META-INF/NOTICE'
          }
      }
      
      dependencies {
          compile fileTree(dir: 'libs', include: ['*.jar'])
          compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.0-rc2'
          compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0-rc2'
      }
      

        Issue Links

          Activity

          Nelson MELINA created issue -
          Nelson MELINA made changes -
          Field Original Value New Value
          Description Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity .java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.torointl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                      at android.app.ActivityThread.access$800(ActivityThread.java:135)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5017)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                      at dalvik.system.NativeStart.main(Native Method)
          {noformat}
          Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity .java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                      at android.app.ActivityThread.access$800(ActivityThread.java:135)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5017)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                      at dalvik.system.NativeStart.main(Native Method)
          {noformat}
          Nelson MELINA made changes -
          Description Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity .java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                      at android.app.ActivityThread.access$800(ActivityThread.java:135)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5017)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                      at dalvik.system.NativeStart.main(Native Method)
          {noformat}
          Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity.java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                      at android.app.ActivityThread.access$800(ActivityThread.java:135)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5017)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                      at dalvik.system.NativeStart.main(Native Method)
          {noformat}
          Nelson MELINA made changes -
          Description Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity.java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                      at android.app.ActivityThread.access$800(ActivityThread.java:135)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5017)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                      at dalvik.system.NativeStart.main(Native Method)
          {noformat}
          Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity.java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                      at android.app.ActivityThread.access$800(ActivityThread.java:135)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5017)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                      at dalvik.system.NativeStart.main(Native Method)
          {noformat}

          build.gradle file :
          {noformat}
          apply plugin: 'com.android.application'

          android {
              compileSdkVersion 19
              buildToolsVersion "19.1.0"

              defaultConfig {
                  applicationId "com.torointl.log4j2xtest"
                  minSdkVersion 19
                  targetSdkVersion 19
                  versionCode 1
                  versionName "1.0"
              }
              buildTypes {
                  release {
                      runProguard false
                      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                  }
              }
              packagingOptions {
                  exclude 'META-INF/LICENSE'
                  exclude 'META-INF/NOTICE'
              }
          }

          dependencies {
              compile fileTree(dir: 'libs', include: ['*.jar'])
              compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.0-rc2'
              compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0-rc2'
          }
          {noformat}
          Nelson MELINA made changes -
          Description Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity.java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                      at android.app.ActivityThread.access$800(ActivityThread.java:135)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5017)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                      at dalvik.system.NativeStart.main(Native Method)
          {noformat}

          build.gradle file :
          {noformat}
          apply plugin: 'com.android.application'

          android {
              compileSdkVersion 19
              buildToolsVersion "19.1.0"

              defaultConfig {
                  applicationId "com.torointl.log4j2xtest"
                  minSdkVersion 19
                  targetSdkVersion 19
                  versionCode 1
                  versionName "1.0"
              }
              buildTypes {
                  release {
                      runProguard false
                      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                  }
              }
              packagingOptions {
                  exclude 'META-INF/LICENSE'
                  exclude 'META-INF/NOTICE'
              }
          }

          dependencies {
              compile fileTree(dir: 'libs', include: ['*.jar'])
              compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.0-rc2'
              compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0-rc2'
          }
          {noformat}
          Hi guys, i'm trying to use Log4J2 in an Android (19) application and it's not working. Here is the code i have and the stacktrace i obtain when running the application.

          Am i missing something or is Log4J2 not working yet in an Android environment ?

          {code:title=MyActivity.java|borderStyle=solid}
          import org.apache.logging.log4j.LogManager;
          import org.apache.logging.log4j.Logger;


          public class MyActivity extends Activity {

              static final Logger logger = LogManager.getLogger(MyActivity.class.getName());

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_my);
                  logger.error("TEST ############################################");
              }
          {code}

          {noformat}
          07-08 10:40:23.401 1307-1307/com.intl.log4j2xtest E/dalvikvm﹕ Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          07-08 10:40:23.441 1307-1307/com.intl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION: main
              Process: com.intl.log4j2xtest, PID: 1307
              java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JndiLookup
                      at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:75)
                      at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:99)
                      at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:29)
                      at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:63)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:144)
                      at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:72)
                      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
                      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
                      at com.intl.log4j2xtest.MyActivity.<clinit>(MyActivity.java:16)
                      at java.lang.Class.newInstanceImpl(Native Method)
                      at java.lang.Class.newInstance(Class.java:1208)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                      at android.app.ActivityThread.access$800(ActivityThread.java:135)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5017)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                      at dalvik.system.NativeStart.main(Native Method)
          {noformat}

          build.gradle file :
          {noformat}
          apply plugin: 'com.android.application'

          android {
              compileSdkVersion 19
              buildToolsVersion "19.1.0"

              defaultConfig {
                  applicationId "com.intl.log4j2xtest"
                  minSdkVersion 19
                  targetSdkVersion 19
                  versionCode 1
                  versionName "1.0"
              }
              buildTypes {
                  release {
                      runProguard false
                      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                  }
              }
              packagingOptions {
                  exclude 'META-INF/LICENSE'
                  exclude 'META-INF/NOTICE'
              }
          }

          dependencies {
              compile fileTree(dir: 'libs', include: ['*.jar'])
              compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.0-rc2'
              compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0-rc2'
          }
          {noformat}
          Nelson MELINA made changes -
          Summary Log4J2 on Android : Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup Log4J 2 on Android : Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          Gary Gregory made changes -
          Summary Log4J 2 on Android : Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup Android: Could not find class 'javax.naming.InitialContext', referenced from method org.apache.logging.log4j.core.lookup.JndiLookup.lookup
          Gary Gregory made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.0 [ 12324757 ]
          Resolution Fixed [ 1 ]
          Gary Gregory made changes -
          Attachment LOG4J2-703-gg.diff [ 12655679 ]
          Gary Gregory made changes -
          Link This issue is a clone of LOG4J2-712 [ LOG4J2-712 ]
          Gary Gregory made changes -
          Link This issue is a clone of LOG4J2-713 [ LOG4J2-713 ]
          Gary Gregory made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Nelson MELINA made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Remko Popma made changes -
          Link This issue is superceded by LOG4J2-716 [ LOG4J2-716 ]
          Remko Popma made changes -
          Link This issue relates to LOG4J2-719 [ LOG4J2-719 ]
          Remko Popma made changes -
          Fix Version/s 2.0.1 [ 12327381 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Nelson MELINA
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development