Skip to main content
Version: 1.2.x

Debugging

Key Points
  • View the browser's console window to see Durandal's activity.
  • Use system.log(...) or system.error(...) for application messages.
  • Disable debug mode before releasing to production. :::

Explanation​

Durandal logs much of it's internal activity using it's system.log function. It's also a great way for the application developer to add logging. It differs from a straight console.log in that it works correctly on every platform and output of this log is sent to the console only if debugging is enabled. You can turn debugging on manually at any time by requiring the system module and calling debug(true). Likewise, you can disable debugging by passing false.

A common technique is to turn debugging on in your main.js. You can use r.js pragmas to make debug only enable when not optimized for deploy. Here's an example of how that would work:

    //>>excludeStart("build", true);
system.debug(true);
//>>excludeEnd("build");

The .NET optimizer automatically defines a "build" pragma as part of its default r.js configuration. :::

note

During application development, make sure your browser is set up to ignore it's cache or you may not get your latest JS/HTML changes.