tony19/logback-android — Issue #3: NetworkOnMainThreadException during initialization
Author: benzht
Created: 2011-11-22 12:17:19+00:00
State: open

Running on Android emulator, API level 14, logback-android throws this exception during its initialization because it accesses the network. The exception can be prevented by manually configuring [StrictMode](https://developer.android.com/reference/android/os/StrictMode.html) to allow networking, but it is slightly annoying that you have to do that.

Thanks a lot for this package! It takes a lot of work away from my project!
Hartmut

```
11-22 12:38:03.670: I/System.out(1528): 12:38:03,579 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@3:16 - RuntimeException in Action for tag [configuration] android.os.NetworkOnMainThreadException
11-22 12:38:03.670: I/System.out(1528):	at android.os.NetworkOnMainThreadException
11-22 12:38:03.670: I/System.out(1528):	at	at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1084)
11-22 12:38:03.670: I/System.out(1528):	at	at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
11-22 12:38:03.670: I/System.out(1528):	at	at java.net.InetAddress.getLocalHost(InetAddress.java:371)
11-22 12:38:03.670: I/System.out(1528):	at	at ch.qos.logback.core.util.ContextUtil.getLocalHostName(ContextUtil.java:32)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.core.util.ContextUtil.addHostNameAsProperty(ContextUtil.java:41)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.classic.joran.action.ConfigurationAction.begin(ConfigurationAction.java:48)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:147)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:133)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:96)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:55)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:85)
11-22 12:38:03.681: I/System.out(1528):	at	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:158)
11-22 12:38:03.681: I/System.out(1528):	at	at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
11-22 12:38:03.681: I/System.out(1528):	at	at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:54)
11-22 12:38:03.681: I/System.out(1528):	at	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
11-22 12:38:03.690: I/System.out(1528):	at	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
11-22 12:38:03.690: I/System.out(1528):	at	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:279)
11-22 12:38:03.690: I/System.out(1528):	at	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:252)
11-22 12:38:03.690: I/System.out(1528):	at	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:265)
...
```