Android Question Send Log output to file on device?

Gentry

Member
Licensed User
Longtime User
I'm trying to debug a app that uses geofences, so not connected to the IDE. Is there a (hopefully elegant) way to RedirectOutput (like B4J) but that captures the log output (with #BridgeLogger:True) to a local file?

Would be super handy. If it's not already there, consider this a feature request. ;)

Thanks,
Gentry
 

Peter Simpson

Expert
Licensed User
Longtime User
Hmm try starting with this.
B4X:
Sub LogCat_LogCatData (Buffer() As Byte, Length As Int)
 
End Sub

This is what you are looking for, but you will see lots of unfiltered logs from your phone.

12-30 21:19:12.041 1414 1414 I B4A : 12-30 21:19:06.959 1414 1414 I B4A : 12-30 21:19:02.576 1414 1414 I B4A : 12-30 21:18:57.201 1414 1414 I B4A : 12-30 21:18:52.616 1414 1414 I B4A : 12-30 21:18:47.814 1414 1414 I B4A : 12-30 21:18:42.503 1414 1414 I B4A : 12-30 21:18:38.019 1414 1414 I B4A : :12.502 1414 1414 I B4A : 12-30 21:18:09.034 1414 1414 I B4A : 12-30 21:18:05.968 1414 1414 I B4A : 12-30 21:18:03.323 1414 1414 I B4A : 12-30 21:18:01.093 1414 1414 I B4A : 12-30 2
12-30 21:19:12.041 1414 1414 I B4A : 12-30 21:19:06.959 1414 1414 I B4A : 12-30 21:19:02.576 1414 1414 I B4A : 12-30 21:18:57.201 1414 1414 I B4A : 12-30 21:18:52.616 1414 1414 I B4A : 12-30 21:18:47.814 1414 1414 I B4A : 12-30 21:18:42.503 1414 1414 I B4A : 12-30 21:18:38.019 1414 1414 I B4A : 12-30 21:18:33.964 1414 1414 I B4A : 12-30 21:18:29.201 1414 1414 I B4A : 12-30 21:18:25.035 1414 1414 I B4A : 12-30 21:18:21.488 1414 1414 I B4A : 12-30 21:18:16.685 1414 1414 I B4A : 12-30 21:18:12.502 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.041 1414 1414 I B4A : 12-30 21:19:06.959 1414 1414 I B4A : 12-30 21:19:02.576 1414 1414 I B4A : 12-30 21:18:57.201 1414 1414 I B4A : 12-30 21:18:52.616 1414 1414 I B4A : 12-30 21:18:47.814 1414 1414 I B4A : 12-30 21:18:42.503 1414
12-30 21:19:12.042 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.155 1414 1414 I B4A : 38.019 1414 1414 I B4A : 12-30 21:18:33.964 1414 1414 I B4A : 12-30 21:18:29.201 1414 1414 I B4A : 12-30 21:18:25.035 1414 1414 I B4A : 12-30 21:18:21.488 1414 1414 I B4A : 12-30 21:18:16.685 1414 1414 I B4A : 12-30 21:18:12.597 1414 1414 I B4A : : 12-30 21:17:52.026 1414 1414
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:06.959 1414 1414 I B4A : 12-30 21:19:02.576 1414 1414 I B4A : 12-30 21:18:57.201 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:06.959 1414 1414 I B4A : 12-30 21:19:02.576 1414 1414 I B4A : 12-30 21:18:58.737 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:06.959 1414 1414 I B4A : 12-30 21:19:02.576 1414 1414 I B4A : 12-30 21:18:58.831 1414 1414 I B4A : :18:43.531 1414 1414 I B4A : 12-30 21:18:38.844 1414 1414 I B4A : 12-30 21:18:34.771 1414 1414 I B4A : 12-30 21:18:29.902 1414 1414 I B4A : 12-30 21:18:25.644 1414 1414 I B4A : 12-30 21:18:21.986 1414 1414 I B4A : 12-30 21:18:1
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:06.959 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:07.068 141
Message longer than Log limit (4000). Message was truncated.
9:02.576 1414 1414 I B4A : 12-30 21:18:58.831 1414 1414 I B4A : 12-30 21:18:53.937 1414 1414 I B4A : 12-30 21:18:48.942 1414 1414 I B4A : 12-30 21:18:43.531 1414 1414 I B4A : 12-30 21:18:38.844 1414 1414 I B4A : 12-30 21:18:34.771 1414 1414 I B4A : 12-30 21:18:29.902 1414 1414 I B4A : 12-30 21:18:25.644 1414 1414 I B4A : 12-30 21:18:21.986 1414 1414 I B4A : 12-30 21:18:17.205 1414 1414 I B4A : : 12-30 21:18:09.329 1414 1414 I B4A : 12-30 21:18:06.171 1414 1414 I B4A : 12-30 21:18:03.525 1414 1414 I B4A : 12-30 21:18:01.294 1414 1414 I B4A : 12-30 21:17:56.297 1414 1414 I B4A : 12-30 21:17:52.138 1414 1414 I B4A :
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.576 1414 1414 I B4A : 12-30 21:18:58.831 1414 1414 I B4A : 12-30 21:18:53.937 1414 1414 I B4A : 12-30 21:18:48.942 1414 1414 I B4A : 12-30 21:18:43.531 1414 1414 I B4A : 12-30 21:18:38.844 1414 1414 I B4A : 12-30 21:18:34.771 1414 1414 I B4A : 12-30 21:18:29.902 1414 1414 I B4A : 12-30 21:18:25.644 1414 1414 I B4A : 12-30 21:18:21.987 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.576 1414 1414 I B4A : 12-30 21:18:58.831 1414 1414 I B4A : 12-30 21:18:53.937 1414 1414 I B4A : 12-30 21:18:48.942 1414 1414 I B4A : 12-30 21:18:43.531 1414 1414 I B4A : 12-30 21:18:38.844 1414 1414 I B4A : 12-30 21:18:34.771 1414 1414 I B4A : 12-30 21:18:29.902 1414 1414 I B4A : 12-30
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.576 1414 1414 I B4A : 12-30 21:18:58.831 1414 1414 I B4A : 12-30 21:18:53.937 1414 1414 I B4A : 12-30 21:18:48.942 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.576 1414 1414 I B4A : 12-30 21:18:58.831 1414 1414 I B4A : 12-30 21:18:53.937 1414 1414 I B4A : 12-
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.577 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.671 1414 1414 I B4A : B4A :
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.671 1414 1414 I B4A : 12-30 21:18:58.831 1414 1414 I B4A : 12-30 21:18:53.938 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.155 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.671 1414 1414 I B4A : 12-30 2
12-30 21:19:12.156 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.247 1414 1414 I B4A : : 12-30 21:18:54.054 1414 1414 I B4A : 1414 I B4A : 1414 I B4A : 12-30 21:17:29.288 1414 1414 I B4A : 12-30 20:58:29.247 26827 26827 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.ja
12-30 21:19:12.247 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.671 1414 1414 I B4A : 12-30 21:18:58.831 1414 1414 I B4A : 12-30 21:18:54.054 1414 1414 I B4A : 12-30 21:18:49.035 1414 1414 I B4A : 12-30 21:18:43.531 1414 1414 I B4A : 12-30 21:18:38.844 1414 1414 I B4A : 12-30 21:18:34.771 1414 1414 I B4A : 12-30 21:18:29.902 1414 1414 I B4A : 12-30 21:18:25.645 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.247 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.671 1414 14
Message longer than Log limit (4000). Message was truncated.
831 1414 1414 I B4A : 12-30 21:18:54.054 1414 1414 I B4A : 12-30 21:18:49.035 1414 1414 I B4A : 12-30 21:18:43.531 1414 1414 I B4A : 12-30 21:18:38.844 1414 1414 I B4A : 12-30 21:18:34.771 1414 1414 I B4A : 12-30 21:18:29.902 1414 1414 I B4A : 12-30 21:18:25.753 1414 1414 I B4A :
12-30 21:19:12.247 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.671 1414 1414 I B4A : 12-30 21:18:58.831 1414 1414 I B4A : 12-30 21:18:54.054 1414 1414 I B4A : 12-30 21:18:49.035 1414 1414 I B4A : 12-30 21:18:43.531 1414 1414 I B4A : 12-30 21:18:38.844 1414 1414 I B4A : 12-30 21:18:34.771 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.247 1414 1414 I B4A : 12-30 21:19:07.068 1414 1414 I B4A : 12-30 21:19:02.671 1414 1414 I B4A : 12-30 21:18:58.831 1414 1414 I B4A : 12-30 21:18:54.054 1414 1414 I B4A : 12-30 21:18:49.035 1414 1414 I B4A : 12-30 21:1
12-30 21:19:12.247 1414 1414 I B4A : 12-30 21:19:07.069 1414 1414 I B4A : ~i:Message longer than Log limit (4000). Message was truncated.
12-30 21:19:12.247 1414 1414 I B4A : 12-30 21:19:07.160 1414 1414 I B4A : : 12-30 21:18:38.844 1414 1414 I B4A : 12-30 21:18:34.882 1414 1414 I B4A : 8:17.205 1414 1414 I B4A : 12-30 21:18:12.924 1414 1414 I B4A : 12-30 21:18:09.329 1414 1414 I B4A : 12-30 21:18:06.171 1414 1414 I B4A : 12-30 21:18:03.525 1414 1414 I B4A : 12-30 21:18:01.294 1414 1414 I B4A : 12-30 21:17:56.297 1414 1414 I B4A : 12-30 21:17:52.138 1414 1414 I B4A : 12-30 21:17:47.353 1414 1414 I B4A : 12-30 21:17:42.687 1414 1414 I B4A : 12-30 21:17:38.712 1414 1414 I B4A : 12-

Enjoy...
 
Last edited:
Upvote 0

Gentry

Member
Licensed User
Longtime User
Yes, I guess that is what I was asking for. But it seems like it is logging unfiltered, which is way too much info. Files going to be too big. Is there anyway to filter the content to only include explicit Log() commands?

It seems most of the stuff I don't care about starts with a timestamp, MM-DD, thinking if I drop lines that have '-' in the 3rd position, i might get closer. What is the expected format of the logcat buffer?

Thanks!
 
Upvote 0
Top