Logging EmberData

The ember data models have a toJSON method that extracts the relevant data:


This method uses the JSONSerializer to create the JSON representation.

If you want to log the data in a more app-specific way, you can use serialize:


which uses the serialization strategy you can define in the store's adapter to create a JSON representation of the model.

All objects in an Ember app, including Ember Data models, inherit from Ember.CoreObject, which has a toString method that prints this representation:

<[email protected]:object-name:id>


  • app-name is the name of your application
  • ember-type is the ember type of the object you are logging (can be controller, route etc.)
  • object-name is the name of the object you are logging (name of your model, or controller, or route etc.)
  • id is either a guId create with Ember.guidFor or, for example, the model's id.

You can overwrite this value using the method toStringExtension in your particular model.

For comparison example, here's how logging an application controller could look:

<[email protected]:application::ember324>

Running debug-only code

Ember has a static global method called runInDebug which can run a function meant for debugging.

Ember.runInDebug(() => {
  // this code only runs in dev mode

In a production build, this method is defined as an empty function (NOP). Uses of this method in Ember itself are stripped from the ember.prod.js build.