logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-719) Android throws NetworkOnMainThreadException during Log4j2 initialization
Date Wed, 16 Jul 2014 13:37:04 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-719?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Remko Popma updated LOG4J2-719:
-------------------------------

    Description: 
(Note that it is possible to work around this issue by modifying the policy and added internet
permission to the Android manifest xml file.)

Stacktrace:

{code}
07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Exception Landroid/os/NetworkOnMainThreadException;
thrown while initializing Lcom/torointl/log4j2xtest/MyActivity;
07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Class init failed in
newInstance call (Lcom/torointl/log4j2xtest/MyActivity;)
07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ threadid=1: thread
exiting with uncaught exception (group=0xa4d72b20)
07-15 14:38:37.639    1243-1243/com.torointl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION:
main
    Process: com.torointl.log4j2xtest, PID: 1243
    java.lang.ExceptionInInitializerError
            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)
     Caused by: android.os.NetworkOnMainThreadException
            at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
            at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
            at java.net.InetAddress.getLocalHost(InetAddress.java:365)
            at org.apache.logging.log4j.core.util.NetUtils.getLocalHostname(NetUtils.java:47)
            at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:356)
            at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:416)
            at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:146)
            at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
            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:14)
            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)
{code}

  was:
Stacktrace:

{code}
07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Exception Landroid/os/NetworkOnMainThreadException;
thrown while initializing Lcom/torointl/log4j2xtest/MyActivity;
07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Class init failed in
newInstance call (Lcom/torointl/log4j2xtest/MyActivity;)
07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ threadid=1: thread
exiting with uncaught exception (group=0xa4d72b20)
07-15 14:38:37.639    1243-1243/com.torointl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION:
main
    Process: com.torointl.log4j2xtest, PID: 1243
    java.lang.ExceptionInInitializerError
            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)
     Caused by: android.os.NetworkOnMainThreadException
            at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
            at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
            at java.net.InetAddress.getLocalHost(InetAddress.java:365)
            at org.apache.logging.log4j.core.util.NetUtils.getLocalHostname(NetUtils.java:47)
            at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:356)
            at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:416)
            at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:146)
            at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
            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:14)
            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)
{code}


> Android throws NetworkOnMainThreadException during Log4j2 initialization
> ------------------------------------------------------------------------
>
>                 Key: LOG4J2-719
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-719
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Configurators, Core
>    Affects Versions: 2.0
>         Environment: Android
>            Reporter: Remko Popma
>            Assignee: Remko Popma
>             Fix For: 2.1
>
>
> (Note that it is possible to work around this issue by modifying the policy and added
internet permission to the Android manifest xml file.)
> Stacktrace:
> {code}
> 07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Exception Landroid/os/NetworkOnMainThreadException;
thrown while initializing Lcom/torointl/log4j2xtest/MyActivity;
> 07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ Class init failed
in newInstance call (Lcom/torointl/log4j2xtest/MyActivity;)
> 07-15 14:38:37.627    1243-1243/com.torointl.log4j2xtest W/dalvikvm﹕ threadid=1: thread
exiting with uncaught exception (group=0xa4d72b20)
> 07-15 14:38:37.639    1243-1243/com.torointl.log4j2xtest E/AndroidRuntime﹕ FATAL EXCEPTION:
main
>     Process: com.torointl.log4j2xtest, PID: 1243
>     java.lang.ExceptionInInitializerError
>             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)
>      Caused by: android.os.NetworkOnMainThreadException
>             at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
>             at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
>             at java.net.InetAddress.getLocalHost(InetAddress.java:365)
>             at org.apache.logging.log4j.core.util.NetUtils.getLocalHostname(NetUtils.java:47)
>             at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:356)
>             at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:416)
>             at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:146)
>             at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
>             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:14)
>             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)
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message