7

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.

3 Answers 3

10

Update, in newer Android versions that is:

adb logcat browser:V *:S
Sign up to request clarification or add additional context in comments.

2 Comments

this doesn't give me much in 4.2.2 or 4.4.2, any solution?
@David Where do I have to run this command exactly please? I am using android studio
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.

5 Comments

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?
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: <nanaze.com/2009/01/debugging-javascript-on-android.html> I've updated my answer to reflect his solution.
That indeed suppressed all of the other messages, but the console.logs are not displaying either. It may be too strict?
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.
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...
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++.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.