The Twilio Voice JavaScript SDK (formerly "Twilio Client") allows users to enable reporting of additional debug-level logging details in your browser console. These debug logs can be helpful for diagnosing issues with your application or connection. This guide will walk you through enabling and viewing the debug-level logging in your Twilio Voice JS SDK application.
Enable Debugging in the Twilio Voice JavaScript Quickstart
When using the Twilio Voice JavaScript SDK Quickstarts, debugging is enabled by default. To see this in the code, open the file Quickstart.js, and find logLevel: 1
, on Line 68, under the Twilio.Device function.
Your code should look something like this:
...
// Instantiate a new Twilio.Device
function intitializeDevice() {
logDiv.classList.remove("hide");
log("Initializing device");
device = new Twilio.Device(token, {
logLevel: 1,
...
Enable Debugging with Twilio.js
For your custom Twilio Voice JavaScript SDK application, debugging works much the same way.
Twilio.js 2.0+
In SDK 2.0, the debug
property was deprecated and replaced with logLevel
. The logLevel property takes an integer 0-5 instead of a string, so to enable debug logging, you need to use logLevel: 1
.
Twilio.js 1.5+
In SDK 1.5.x and later, Twilio.Device
allows for direct construction, letting users run multiple instances on the same page. When you pass a token to Twilio.Device, Device.setup()
is automatically run. This means you won't need to call it out separately, and you can just add the debug: true,
option here. This is the method used in the latest versions of the Quickstart applications. Take a look at the sample code above for an example.
Twilio.js 1.3.x - 1.4.x
In older WebRTC versions of the Twilio Voice JavaScript SDK, debugging needs to be called out as an option in Twilio.Device.setup().
Twilio.Device.setup(token, { debug: true });
For full documentation, see Twilio Voice JS SDK: Twilio.Device.
View Debug Logs
Once enabled, you'll be able to see additional logging information about your session in the browser console.
The browser console can be viewed via the following methods:
Browser | OS | Commands |
Chrome | Mac OS | Command + Option + J |
Chrome | Windows | Control + Shift + J |
Firefox | Mac OS | Command + Shift + J |
Firefox | Windows | Control + Shift + J |
Edge | Windows | Press F12, then Control + 2 |
Safari | Mac OS | Command + Option + C Note: The Develop menu must first be enabled. |
The Console logs the Twilio Access Token used for your session, as well as any errors. If you need to reach out to our Support team, please include any details from your debugging logs, as these will be helpful for diagnosing your issues. If you'd like to capture these logs in a .HAR file in order to package the logs for our support team, please see the instructions here.