6

So I am running logcat on my Incredible 2 connected to my computer and am trying to debug a web app I am working on. Unfortunately, the device is spamming the console so I can't see any of my console.logs from my javascript. Does anyone know of a way to filter out everything but the console.logs coming from the browser? I tried running logcat with these options

adb logcat -s "console"

thinking it would filter out everything but the console, since the android docs says the the browser console.logs spit out in this format listed here:

Console: Hello World http://www.example.com/hello.html :82

http://developer.android.com/guide/webapps/debugging.html

anyone know the real trick to this? Thanks.

gabaum10
  • 3,769
  • 3
  • 48
  • 89

3 Answers3

10

Update, in newer Android versions that is:

adb logcat browser:V *:S
David
  • 126
  • 1
  • 3
2

Can console.log be used to specify a tag? If so, you can use logcat to get only entries with a given tag with this:

adb logcat MYTAG:V

Turns out that console.log() specifies a tag of WebCore automatically, so you should be able to filter things the way you want like this:

adb logcat WebCore:V *:S

This means, "Show me everything tagged WebCore, and nothing that isn't." Other people have had success using browser instead of WebCore (Is there a way to enable the JavaScript Error/Debug Console for Safari within Android?), so try both and see what works.

Community
  • 1
  • 1
David Merriman
  • 6,056
  • 1
  • 18
  • 18
  • Yeah, if you look at the link I posted above, you can see that the console spits out something in the format "Console: stuff". Logically, if I do something like this: `adb logcat Console:V` right? – gabaum10 Jan 27 '12 at 14:16
  • I did some more looking at what the `console.log` function looks like and what it does. Seems like someone else has already had this issue and found a fix for it: I've updated my answer to reflect his solution. – David Merriman Jan 27 '12 at 17:01
  • That indeed suppressed all of the other messages, but the console.logs are not displaying either. It may be too strict? – gabaum10 Jan 27 '12 at 17:14
  • Sounds like it's just an issue of finding the right tag. I'd recommend using the LogCat viewer that comes with the ADT plugin for eclipse, as it will help you see the tag for every message that comes in. – David Merriman Jan 27 '12 at 17:55
  • Ah dang, I was using netbeans for the web dev and really didn't want to have to install eclipse too. Looks like I really don't have a choice... – gabaum10 Jan 27 '12 at 19:00
0

Any of above solutions not working for me. What I did was, save the logs in to a file using save option and search text 'Web Console' in the file using notepad++.

Madura Pradeep
  • 2,378
  • 1
  • 30
  • 34