Comments (7)
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.
Can this be fixed?
Thanks
from logback-android.
Please test this snapshot of logback-android-1.0.6-2. Thanks.
from logback-android.
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.
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.
Ok, thanks for testing.
from logback-android.
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)
- How to append Build Version Number with Log Main File HOT 1
- Document usage compatible with the standard JUnit tests
- write log after app killed ,how to write log real time HOT 1
- Log file is not creating at very first time when app gets launched in android. HOT 5
- No log is printed with Slf4j 2.x.x HOT 10
- Missing SSL parameter configuration HOT 1
- Dependency Dashboard
- how to rename locback.xml as logback-demo.xml HOT 1
- Caused by java.lang.NullPointerException Attempt to invoke interface method 'void androidx.appcompat.view.menu.d.u(int)' on a null object reference HOT 1
- ArrayIndexOutOfBoundsException on Android 10
- LogcatAppender show errors for logs' "highlighting".
- Lazy setting does not work
- Can't Create Logger: DateTokenConverter not found? HOT 2
- The log cannot be written correctly in the case of multi-process Android application? HOT 2
- Cannot create AAR with ./scripts/makejar.sh HOT 1
- Excepton in kotlin app with jetpack compose, only in release mode HOT 1
- Missing transitive dependency on slf4j-api-2.x
- The release version turns on minifyEnabled, and the file name is printed as null. <pattern>[%date] [%file:%line] - %msg%n</pattern>
- logback-android and logback-classic ILoggingEvent binary incompatibility getMarkers vs getMarkerList HOT 1
- can not write to the file that under the android getExternalFilesDir()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logback-android.