Git Product home page Git Product logo

Comments (7)

tony19 avatar tony19 commented on August 16, 2024

It looks like the SyslogAppender in Android's strict mode causes a NetworkOnMainThreadException:

I/System.out( 2859): 18:07:18,030 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@0:0 - RuntimeException in Action for tag [appender] android.os.NetworkOnMainThreadException
I/System.out( 2859):    at android.os.NetworkOnMainThreadException
I/System.out( 2859):    at  at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
I/System.out( 2859):    at  at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
I/System.out( 2859):    at  at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
I/System.out( 2859):    at  at java.net.InetAddress.getByName(InetAddress.java:289)
I/System.out( 2859):    at  at ch.qos.logback.core.net.SyslogOutputStream.(Unknown Source)
I/System.out( 2859):    at  at ch.qos.logback.core.net.SyslogAppenderBase.start(Unknown Source)
I/System.out( 2859):    at  at ch.qos.logback.classic.net.SyslogAppender.start(Unknown Source)
I/System.out( 2859):    at  at ch.qos.logback.core.joran.action.AppenderAction.end(Unknown Source)
I/System.out( 2859):    at  at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Unknown Source)
I/System.out( 2859):    at  at ch.qos.logback.core.joran.spi.Interpreter.endElement(Unknown Source)
I/System.out( 2859):    at  at ch.qos.logback.core.joran.spi.Interpreter.endElement(Unknown Source)
I/System.out( 2859):    at  at ch.qos.logback.core.joran.spi.EventPlayer.play(Unknown Source)
I/System.out( 2859):    at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(Unknown Source)
I/System.out( 2859):    at  at ch.qos.logback.classic.util.ContextInitializer.configureByManifest(Unknown Source)
I/System.out( 2859):    at  at ch.qos.logback.classic.util.ContextInitializer.autoConfig(Unknown Source)
I/System.out( 2859):    at  at org.slf4j.impl.StaticLoggerBinder.init(Unknown Source)
I/System.out( 2859):    at  at org.slf4j.impl.StaticLoggerBinder.(Unknown Source)
I/System.out( 2859):    at  at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
I/System.out( 2859):    at  at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
I/System.out( 2859):    at  at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:279)
I/System.out( 2859):    at  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:252)
I/System.out( 2859):    at  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:265)
I/System.out( 2859):    at  at com.example.helloandroid.ItemListActivity.(ItemListActivity.java:16)
I/System.out( 2859):    at  at java.lang.Class.newInstanceImpl(Native Method)
I/System.out( 2859):    at  at java.lang.Class.newInstance(Class.java:1319)
I/System.out( 2859):    at  at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
I/System.out( 2859):    at  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
I/System.out( 2859):    at  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
I/System.out( 2859):    at  at android.app.ActivityThread.access$600(ActivityThread.java:130)
I/System.out( 2859):    at  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
I/System.out( 2859):    at  at android.os.Handler.dispatchMessage(Handler.java:99)
I/System.out( 2859):    at  at android.os.Looper.loop(Looper.java:137)
I/System.out( 2859):    at  at android.app.ActivityThread.main(ActivityThread.java:4745)
I/System.out( 2859):    at  at java.lang.reflect.Method.invokeNative(Native Method)
I/System.out( 2859):    at  at java.lang.reflect.Method.invoke(Method.java:511)
I/System.out( 2859):    at  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
I/System.out( 2859):    at  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
I/System.out( 2859):    at  at dalvik.system.NativeStart.main(Native Method)

from logback-android.

andpro avatar andpro commented on August 16, 2024

Can this be fixed?

Thanks

from logback-android.

tony19 avatar tony19 commented on August 16, 2024

Please test this snapshot of logback-android-1.0.6-2. Thanks.

from logback-android.

andpro avatar andpro commented on August 16, 2024

Hi,

I double checked my test and looks like I do not get the Network exception as you do. The server does show the log mesg so the syslog did push the log mesg to server.
I only get violation for disk read at start up which may be ok as it is reading the configuration file.
I also checked with the snapshot and I get the same. Here is my code.

StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads().detectDiskWrites().detectNetwork()
.penaltyLog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects().detectLeakedClosableObjects()
.penaltyLog().build());

    super.onCreate(savedInstanceState);
    logger = LoggerFactory.getLogger(SyslogLogbackActivity.class);
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    StatusPrinter.print(lc);
    setContentView(R.layout.main);
    logger.debug("Hello Test Strict Mode");

config file (space added around >< as the comments is not showing properly.

< configuration debug="true" >
< appender name="SYSLOG" class="ch.qos.logback.classic.net.SyslogAppender" >
< syslogHost>AAA.REMOVED.com
< port>11111
< facility>AUTH
< suffixPattern>[%thread] %logger %msg
</ appender >
< root level="DEBUG" >
< appender-ref ref="SYSLOG" />
</ root >
</ configuration >

from logback-android.

andpro avatar andpro commented on August 16, 2024

Hi,

In the snapshot the syslog does not work. Went back to the last released jar and it works fine on it.
Thanks

from logback-android.

tony19 avatar tony19 commented on August 16, 2024

Ok, thanks for testing.

from logback-android.

lock avatar lock commented on August 16, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from logback-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.