• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
B2G OS
  1. MDN
  2. Archive of obsolete content
  3. B2G OS
  4. Debugging on Firefox OS
  5. On-device console logging

On-device console logging

In This Article
  1. Enabling console logging
  2. Logging
  3. Using logcat
  4. Shake to save system log
  5. Hardware buttons (VolumeUp+sleep) to save system log

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.

 

Document Tags and Contributors

Tags: 
  • Debugging
  • Firefox OS
  • Guide
  • Logging
  • web console
 Contributors to this page: chrisdavidmills, AndrewSutherland, kscarfone, dobinator, Akurado, simone, breck, Charles5306, Sheppy
 Last updated by: chrisdavidmills, Feb 27, 2017, 2:59:43 AM
See also
  1. Build and install
    1. Build and install overview
    2. B2G OS build process summary
    3. Build prerequisites
    4. Preparing for your first build
    5. Building B2G OS
    6. B2G installer add-on
    7. Building B2G OS for Flame on Mac OS X
    8. Choosing how to run Gaia or B2G OS
    9. Compatible Devices
    10. Installing B2G OS on a mobile device
    11. Creating and applying B2G OS update packages
    12. Building and installing FOTA community builds
    13. B2G build variables reference sheet
  2. Porting B2G OS
    1. Porting overview
    2. Porting basics
    3. Porting on CyanogenMod
  3. Developing Gaia
    1. Developing Gaia overview
    2. Running the Gaia codebase
    3. Run Gaia on desktop using Mulet
    4. Understanding the Gaia codebase
    5. Making Gaia code changes
    6. Testing Gaia code changes
    7. Submitting a Gaia patch
    8. Gaia build system primer
    9. Different ways to run Gaia
    10. Make options reference
    11. Gaia tools reference
  4. B2G OS APIs