In addition to being able to log console output and view it using the remote web console, you can log console output into the device's onboard file store, then retrieve the logs later from your computer using the logcat
utility and a USB connection. This article covers how to enable this feature, how to perform the logging, and how to retrieve the logs.
Enabling console logging
On production builds of Firefox OS, console logging (for example console.log()
) is disabled by default. In order to enable it, go to your device's Developer settings and enable the Console Enabled preference.
Logging
Once logging has been enabled, it works just like logging on desktop Firefox OS. You simply use the methods on the console
object to log text to the console. For example:
console.info("Starting up the foobar hardware!"); var err = foobar.start(); if (err) { console.error("--Error %d starting up the foobar hardware!", err); }
Note: See console
for details on logging features available to you.
Using logcat
Because the log output is stored on the Firefox OS device, and there isn't currently any user interface for viewing these logs on the device, you'll need to fetch them to a computer for review. You'll need to use the logcat
command from adb
, which is part of the Android SDK (see Installing ADB).
Fortunately, using the logcat
is simple: once adb
is installed and your device is connected to your computer via USB, you can use it from the terminal like this:
adb logcat
This should result in the device's log (stored at /dev/log/system/
) being output into the terminal. For example:
I/Vold ( 107): Vold 2.1 (the revenge) firing up D/Vold ( 107): Volume sdcard state changing -1 (Initializing) -> 0 (No-Media) D/Vold ( 107): Volume emmc state changing -1 (Initializing) -> 0 (No-Media) D/Vold ( 107): Volume sdcard state changing 0 (No-Media) -> 2 (Pending) D/Vold ( 107): Volume sdcard state changing 2 (Pending) -> 1 (Idle-Unmounted) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) W/Vold ( 107): Duplicate state (1) D/Vold ( 107): Volume emmc state changing 0 (No-Media) -> 2 (Pending) D/Vold ( 107): Volume emmc state changing 2 (Pending) -> 1 (Idle-Unmounted) D/VoldCmdListener( 107): volume list D/VoldCmdListener( 107): volume mount sdcard I/Vold ( 107): /dev/block/vold/179:20 being considered for volume sdcard D/Vold ( 107): Volume sdcard state changing 1 (Idle-Unmounted) -> 3 (Checking) W/Vold ( 107): Skipping fs checks I/Vold ( 107): Device /dev/block/vold/179:20, target /mnt/sdcard mounted @ /mnt/secure/staging D/Vold ( 107): Volume sdcard state changing 3 (Checking) -> 4 (Mounted) D/VoldCmdListener( 107): volume mount emmc I/Vold ( 107): /dev/block/vold/179:33 being considered for volume emmc D/Vold ( 107): Volume emmc state changing 1 (Idle-Unmounted) -> 3 (Checking) W/Vold ( 107): Skipping fs checks I/Vold ( 107): Device /dev/block/vold/179:33, target /mnt/emmc mounted @ /mnt/secure/staging D/Vold ( 107): Volume emmc state changing 3 (Checking) -> 4 (Mounted) etc.
Shake to save system log
On Firefox OS 2.2+ there is a developer setting called Shake to save system log. When enabled this allows you to shake your phone to dump the contents of the system log/logcat to the device's SD card, at logs/<datetime>.
Hardware buttons (VolumeUp+sleep) to save system log
For v3.0+ bug 1136777 has added the ability to trigger saving logs by pressing the "volume up" hardware button and sleep button at the same time. (And the somewhat similar "volume down" and sleep will take a screenshot.) This does not require the "shake to save system log" preference to be enabled.