How to watch console.logs in ionic emulator?

kramer65 picture kramer65 · Feb 19, 2015 · Viewed 48.9k times · Source

I'm building an app using the Ionic framework, which I've done in the browser until now. Because I now want to use the cordovaOauth plugin I need to use the emulator. The problem is that I can't see any console.log() in the emulator as I do in the browser, which makes it hard to debug.

Does anybody know how in Ionic/Cordova I can make use of console logging in the emulator? All tips are welcome!

Answer

Carlos Barcelona picture Carlos Barcelona · Mar 27, 2015

Just enable the console logs in the emulator. Here my example:

> ionic emulate ios --livereload

  Setup Live Reload
  Running dev server: http://localhost:8100
  Adding in default Ionic hooks
  Running live reload server: http://localhost:35729
  Watching : [ 'www/**/*', '!www/lib/**/*' ]
  Ionic server commands, enter:
    restart or r to restart the client app from the root
    goto or g and a url to have the app navigate to the given url
    consolelogs or c to enable/disable console log output
    serverlogs or s to enable/disable server log output
    quit or q to shutdown the server and exit

Type consolelogs in the command line and hit enter.

  consolelogs

  Console log output: enabled
  Loading: /?restart=382451
  ionic $ 0     498458   log      Hi there! This is from console.log