Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log.d() or Log.e() in android prints unwanted extra texts

look at the image to get more ideaWhen I simply log a message in android app, Android Monitor print too much extra unwanted garbage text like: Code:

Log.d(TAG, "From: " + "34369257099");
Log.d(TAG, "Message Notification Body: " + "Hello");

Output in android monitor:

10-01 14:15:33.262 18193-23771/com.xxxxx.xxxxxx D/MyFirebaseMsgService: From: 34369257099
10-01 14:15:33.262 18193-23771/com.xxxxx.xxxxxx D/MyFirebaseMsgService: Message Notification Body: Hello

[ 10-01 14:15:33.490 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9871) p->msg.arg1(0) OPEN


[ 10-01 14:15:33.490 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/net/xt_qtaguid/stats | grep 10206

[ 10-01 14:15:33.527 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:33.686 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9872) p->msg.arg1(0) OPEN


[ 10-01 14:15:33.686 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/18193/stat

[ 10-01 14:15:33.701 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:33.723 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9873) p->msg.arg1(0) OPEN


[ 10-01 14:15:33.723 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/stat

[ 10-01 14:15:33.740 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:34.051 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9874) p->msg.arg1(0) OPEN


[ 10-01 14:15:34.051 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/net/xt_qtaguid/stats | grep 10206

[ 10-01 14:15:34.086 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:34.258 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9875) p->msg.arg1(0) OPEN


[ 10-01 14:15:34.258 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/18193/stat

[ 10-01 14:15:34.274 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:34.294 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9876) p->msg.arg1(0) OPEN


[ 10-01 14:15:34.294 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/stat

[ 10-01 14:15:34.315 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:34.613 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9877) p->msg.arg1(0) OPEN


[ 10-01 14:15:34.613 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/net/xt_qtaguid/stats | grep 10206

[ 10-01 14:15:34.648 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:34.831 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9878) p->msg.arg1(0) OPEN


[ 10-01 14:15:34.831 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/18193/stat

[ 10-01 14:15:34.849 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:34.867 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9879) p->msg.arg1(0) OPEN


[ 10-01 14:15:34.867 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/stat

[ 10-01 14:15:34.885 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:35.176 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9880) p->msg.arg1(0) OPEN


[ 10-01 14:15:35.176 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/net/xt_qtaguid/stats | grep 10206

[ 10-01 14:15:35.210 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:35.404 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9881) p->msg.arg1(0) OPEN


[ 10-01 14:15:35.404 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/18193/stat

[ 10-01 14:15:35.421 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:35.439 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9882) p->msg.arg1(0) OPEN


[ 10-01 14:15:35.439 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/stat

[ 10-01 14:15:35.457 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:35.738 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9883) p->msg.arg1(0) OPEN


[ 10-01 14:15:35.738 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/net/xt_qtaguid/stats | grep 10206

[ 10-01 14:15:35.764 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:35.974 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9884) p->msg.arg1(0) OPEN


[ 10-01 14:15:35.974 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/18193/stat

[ 10-01 14:15:35.990 19060:19060 E/         ]
[adb] cuurent command is A_CLSE 


[ 10-01 14:15:36.009 19060:19060 E/         ]
[adb] handle_packet() t->online(1) p->msg.arg0(9885) p->msg.arg1(0) OPEN


[ 10-01 14:15:36.009 19060:19060 E/         ]
[adb] handle the adb command, and the command = adb shell:cat /proc/stat

Can You please help me solve this? I mean why does this extra text gets printed? and how do I get rid of this? I have used filter to display only package related logs and tried filtering TAG wise too. But see in image attached that still garbage text gets printed in some Logs.

Thanks in Advance

like image 859
Manav Patadia Avatar asked Oct 01 '16 08:10

Manav Patadia


2 Answers

Since the unwanted lines all seem to have '[' in them, we should be able to create a filter that excludes those lines & get what you need (you won't be able to use that character in any of your log statements).

Create a filter using ^[^\[]+$ as the Log Message (& make sure Regex is selected). You'll also have to set either the Log Tag or Package Name or you get everything from other apps that doesn't include '['.

Thanks to here for the help with the regex.

screenshot of logcat Filter editor

like image 126
Gary99 Avatar answered Nov 15 '22 21:11

Gary99


See the image properly to the top right corner, We have something like a basic filter. Using Show Only Selected Application will let you only see what Belongs to your app. you Can Use Edit Filter Configuration to use more complex Filters.

like image 31
jeevan s Avatar answered Nov 15 '22 21:11

jeevan s