Wednesday, March 6, 2019

logging - Problems accessing message logs on Jelly Bean with aLogcat



I have been having problems accessing the K9 log messages using aLogcat, see below for more details. What I would like to know is:




  • Why are no log messages from K9 appearing in the aLogcat log viewer?

  • Does anyone have any suggestions as to how I can see the full text of the errors which are occurring when trying to sync my K9 folders?

  • Could something have changed in Jelly Bean which lead K9's logging to stop working?

  • Since there seem to be remarkably few messages being shown by aLogcat in general, has something has changed in Jelly Bean which could mean that it is no longer able to access all messages?



I have recently been having connection problems with K9. My folders fail to sync and the folder list ends up full of socket errors (libcore.io.ErrnoException:) or ssl errors (javex.net.ssl.SSLException:) etc. where the last checked time should be. I get different messages depending on which problem is occurring at the time, but I can't see the full text of the error message, so it's difficult to guess what the cause might be.


Thinking that the log files might contain more information, I followed the instructions at Recording a debug log, enabled debug logging in K9, installed aLogcat and tried to look at the logs. Sadly, whichever log buffer I select (Main, Events or Radio), there appear to be no messages from K9.


If I add the suggested (k9|AndroidRuntime) regex filter then I see nothing in any of the logs. If I remove it then Main contains mostly garbage collection messages, Events seem to contain mostly messages from aLogcat itself and I haven't seen a log message in Radio yet.


If it makes any difference, I'm using a Nexus 7, but I would have thought that logging would have been to a standard location which wouldn't change between android versions.




Answer




Does anyone have any suggestions as to how I can see the full text of the errors which are occurring when trying to sync my K9 folders?



It seems that there is no way to see these log messages on the device without root access, but if you do have root access, there are a couple of options, either grant the required permissions to aLogcat or consider using a horrible hackTM to view them directly.


View the log files on your PC or workstation via adb


If you can connect your Android device to a PC or workstation, then you can access the logs via the adb command.


To do this on Windows, first you will need to install the Android SDK (which will require the Java SE SDK) and add the android-sdk\tools and android-sdk\platform-tools to the system path. Then enable USB debugging on your Nexus 7, plug it in via USB, and install the Android Composite ADB Interface from android-sdk\extras\google\usb_driver (I had to force Windows XP to look here, it wouldn't find the drivers on it's own).


For details of how to get adb up and running without the full Android SDK install, or on Mac or Linux machines, see Izzy's excellent answer to Is there a minimal installation of ADB?


Then you can open a shell (i.e. a cmd window) and run the command:



adb logcat k9:V *:S AndroidRuntime:E


  • I have confirmed that this works on my non-rooted Nexus 7.


Grant permissions to aLogcat


If you have root access, you could consider granting the READ_LOGS permission to aLogcat, as suggested in this post aLogcat/CatLog/Lumberjack not working? Do this ... on the xda-developers forum:


pm grant  android.permission.READ_LOGS

To grant this permission to alogcat or alogcat.donate, you would use one of the following commands, depending on whether you are running the donate version or not:



pm grant org.jtb.alogcat.donate android.permission.READ_LOGS
pm grant org.jtb.alogcat android.permission.READ_LOGS

According to one post on android-developers and the ticket, the permission grant survives reboot and update, but not uninstall/reinstall.


Sadly since this requires root access, whether I run this on the device or on my PC (prefixed by adb shell) I just get the error:


Neither user 12345 nor current process has android.permission.GRANT_REVOKE_PERMISSION


  • I cannot confirm that this works, since my Nexus 7 has not been rooted.



Consider using a horrible hackTM


If you have root access, you could consider making logcat setuid root and running logcat from the device shell, as suggested in this answer to my How can I access android log files on my Nexus 7 without root access?question:


chmod 04755 /system/bin/logcat
logcat k9:V *:S AndroidRuntime:E


  • Again, I cannot confirm that this works and I would probably only use it as a last resort, given the security implications.






Why are no log messages from K9 appearing in the aLogcat log viewer?


Could something have changed in Jelly Bean which lead K9's logging to stop working?


Since there seem to be remarkably few messages being shown by aLogcat in general, has something has changed in Jelly Bean which could mean that it is no longer able to access all messages?



This appears to be a change in Jelly Bean which affects all applications which may try to read the log files.


Apparently READ_LOGS permission is not granted to 3rd party applications in Jelly Bean. Since this link seems to be unreliable:



Today I've tested my application on newest (api 16) emulator before releasing it to Google Play. It turned out that Android now refuses to grant this permission to 3rd party applications. This is weird because I've looked through all Jelly Bean's documented changes and couldn't find anything that mentions READ_LOGS permission.



and later




The protectionLevel for READ_LOGS is now "signature|system|development". The new pipe syntax for protectionLevel is also undocumented (see http://code.google.com/p/android/issues/detail?id=34785).



My suspicion is that aLogcat is only seeing messages generated by itself and it's vm.


For further information, see Flow answer's to my question How active should I expect my Jelly Bean system log file to be?


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...