Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript console.log() on HTC Android devices and adb logcat

I am developing the application in HTML which is calling the console.log() from Javascript to provide me logs during the development about what happens in the web page code.

Unfortunately when I use the adb logcat command to check logs I can see output from all other applications, but not the output from my JavaScript code. I can see even the log from web browser that the page is loaded, but not console.log() output from my JavaScript code executed in the web browser.

According to information on this page (http://developer.android.com/guide/webapps/debugging.html) it should work.

I am testing on HTC WildFire and HTC Desire HD.


Edited after more then 6 months

After some time and experience with different devices (phones, TVs, set top boxes, WebViews, UIWebViews...) my advice is to do the remote logging from JavaScript and not relying on the console.log() or other methods - see the nice trick with the image loading here.

Do not miss the presentation here Hope this helps! STeN

like image 714
STeN Avatar asked Apr 04 '11 12:04

STeN


People also ask

How do I get adb logs from my Android?

Navigate to device settings and enable Developer Options (see section for ADB logs) Navigate to Developer Options and tap on Take/Submit Bug Report. Select Full Report when prompted to get the full device info along with the logs.

How do I view JavaScript logs?

With the Chrome browser open, right-click anywhere in the browser window and select Inspect from the pop-up menu. By default, the Inspect will open the "Elements" tab in the Developer Tools. Click on the "Console" tab which is to the right of "Elements".

What does adb Logcat do?

Android logcat is a command-line tool that dumps a log of system messages, including stack traces when the device throws an error and messages that are written by applications with the "Log" class.


1 Answers

In the default browser on Android 2.3.3 (and presumably from then on) you can simply use the built in javascript console:

  • open the browser
  • go to your webpage
  • type about:debug in the address bar and hit enter
  • you'll see a section for debug options appear if you go into the browser app's settings
  • tick "Show JavaScript Console" if not already enabled
  • refresh your webpage

At the top, you'll see a bar labeled "JavaScript Console".

like image 98
thruflo Avatar answered Oct 05 '22 23:10

thruflo