By Mark Booth


2012-08-14 10:01:34 8 Comments

Summary

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?

Detail

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.

2 comments

@Mark Booth 2012-09-06 09:29:49

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 <pkg> 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?

@Flow 2012-09-06 09:32:33

IIRC adb logcat is still able to get the full android log on Jelly Bean.

@Flow 2012-09-06 10:16:11

It does not require root but you need to enable adb on your device (usually under developer options).

@Mark Booth 2012-09-09 01:35:01

@Flow - I've now confirmed that I can view the log on my PC using adb logcat from there and have updated my answer accordingly. It's still frustrating that I can't find any way to access the logs without root access from the device itself.

@Flow 2012-12-30 13:25:24

It is the whole point in the JB log change that a non-root user can't access the full system log.

@Mark Booth 2012-12-31 19:12:20

@Flow - Yeah, and the whole point of log messages is that you can use them to find out what's going on. JB makes an app like aLogcat pretty pointless, since it can now only access log messages it has created itself!

@HRJ 2013-07-16 18:30:45

I created a simple utility to access log files from a PC: gist.github.com/hrj/5983971

@Izzy 2013-08-15 14:17:46

BTW: It does not require a Windows PC to use ADB. It runs fine on a Mac, too – and I use it without any issues on my Linux machine. Neither does one need a full SDK install with all its dependencies (see: Is there a minimal installation of ADB?). Apart from that: Great and thorough answer :)

@Mark Booth 2013-09-19 10:39:18

Thanks @Izzy, I've updated my answer to reference your answer and make that section more generic.

@Izzy 2013-09-19 11:09:38

Thanks, good job! One more detail: My linked answer also applies to Windows. The full SDK is not needed just for ADB to work :)

@Mark Booth 2013-09-19 11:13:25

That's why I prefixed that para with For details of how to get adb up and running without the full Android SDK install. I prefer self contained answers, so I didn't want to remove my procedure, but I did want to highlight your as an alternative.

@Tsar Ioann 2018-11-14 00:29:20

Thank you! adb logcat k9:V *:S AndroidRuntime:E showed me stacktrace of morning crash at night of the following day! Log was still there!

@onik 2012-08-14 10:52:02

I've seen this behaviour in K9 when my mail server updated it's SSL certificates. The fix was to long-press the account, select Account settings -> Fetching mail -> Incoming server and just hit Next through the pages to confirm your settings until you get the popup about the certificate (this might not appear if everything is OK with the certificate, mine had a wrong vhost). Confirm the certificate and just go through the rest of the settings and you account should start to work.

@Matthew Read 2012-08-28 17:42:17

@MarkBooth Perhaps you should have asked that, we generally prefer questions that don't presuppose a solution.

@Izzy 2012-09-05 15:27:02

@MatthewRead I must agree with Mark here: The 4 items in his summary explicitly state he wants help with the logging issue, and I also do not see the "XY problem" here (presupposed solution). K9 is clearly just the example -- but maybe the question title should be adjusted to underline it: "Using logcat to determine the cause of problems" would match (and focus) better ;)

@Izzy 2012-09-06 10:48:51

@MarkBooth Yepp, tnx -- much clearer now. Also tnx for the detailed answer! Please keep us updated about your progress.

@onik 2012-09-06 11:25:15

Should I delete my answer, since it's completely off-topic after the edits and prone to be downvoted?

@Mark Booth 2012-09-06 12:28:29

It's up to you onik. As I said originally I do appreciate you taking the time to post an answer, but now that I've updated the question your answer looks even more out of place. I suppose you could always wait and see if it gets voted below -3 so you can collect your peer pressure badge. *8')

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] Writing to /dev/log/main from command line

  • 2013-12-03 07:53:19
  • Roman Saveljev
  • 871 View
  • 1 Score
  • 1 Answer
  • Tags:   adb logging

3 Answered Questions

[SOLVED] How can I access android log files on my Nexus 7 without root access?

5 Answered Questions

[SOLVED] Wi-Fi connection dropping

2 Answered Questions

[SOLVED] What is the format of Android's logs?

  • 2012-10-01 15:54:13
  • Scott Severance
  • 12350 View
  • 8 Score
  • 2 Answer
  • Tags:   logging

1 Answered Questions

1 Answered Questions

[SOLVED] Where and how do I read logs for a specific app?

  • 2013-10-23 21:35:24
  • Syl
  • 1748 View
  • 2 Score
  • 1 Answer
  • Tags:   logging

1 Answered Questions

[SOLVED] How active should I expect my Jelly Bean system log file to be?

1 Answered Questions

[SOLVED] Why are all contacts grayed out in Google Talk?

Sponsored Content