Page Contents

You can specify debug strings when you run an application, as explained below, to display specific log output to the console. You can also redirect the output to a file, if desired. These techniques are often helpful in debugging applications.

Using debug strings

The LoopBack framework has a number of built-in debug strings to help with debugging. Specify a string on the command-line via an environment variable as follows:

MacOS and Linux

$ DEBUG=<pattern>[,<pattern>...] node .

Windows

C:\> set DEBUG=<pattern>[,<pattern>...]
C:\> node .

where <pattern> is a string-matching pattern specifying debug strings to match. You can specify as many matching patterns as you wish.

For example (MacOS and Linux):

$ DEBUG=loopback:datasource node .

Or, on Windows:

C:\> set DEBUG=loopback:datasource
C:\> node .

You’ll see output such as (truncated for brevity):

loopback:datasource Settings: {"name":"db","debug":true} -0ms
loopback:datasource Settings: {"name":"geo","connector":"rest",...

You can use an asterisk  (*) in the pattern to match any string. For example the following would match any debug string containing “oracle”:

$ DEBUG=*oracle node .

You can also exclude specific debuggers by prefixing them with a “-“ character. For example, DEBUG=*,-strong-remoting:* would include all debuggers except those starting with “strong-remoting:”.

Debug string format

These strings have the format

module[:area]:fileName

Where:

  • module is the name of the module, for example loopback or loopback-connector-rest.
  • area is an optional identifier such as security or connector to identify the purpose of the module
  • fileName is the name of the JavaScript source file, such as oracle.js.

For example:

loopback:security:access-context

identifies the source file access-context.js in the loopback module (used for security features).

Debug strings reference

Module / Source file String
loopback
loopback/lib/connectors/base-connector.js connector
loopback/lib/connectors/mail.js loopback:connector:mail
loopback/lib/connectors/memory.js memory
loopback/lib/models/access-context.js loopback:security:access-context
loopback/lib/models/acl.js loopback:security:acl
loopback/lib/models/change.js loopback:change
loopback/lib/models/role.js loopback:security:role
loopback/lib/models/user.js loopback:user
loopback-datasource-juggler
loopback-datasource-juggler/lib/datasource.js loopback:datasource
loopback-boot
loopback-boot/lib/compiler.js loopback:boot:compiler
loopback-boot/lib/executor.js loopback:boot:executor
Components
loopback-component-push/lib/providers/apns.js loopback:component:push:provider:apns
loopback-component-push/lib/providers/gcm.js loopback:component:push:provider:gcm
loopback-component-push/lib/push-manager.js loopback:component:push:push-manager
Connectors
loopback-connector-mongodb/lib/mongodb.js loopback:connector:mongodb
loopback-connector-mssql/lib/mssql.js loopback:connector:mssql
loopback-connector-mysql/lib/mysql.js loopback:connector:mysql
loopback-connector-oracle/lib/oracle.js loopback:connector:oracle
loopback-connector-postgresql/lib/postgresql.js loopback:connector:postgresql
loopback-connector-rest/lib/rest-builder.js loopback:connector:rest
loopback-connector-rest/lib/rest-connector.js loopback:connector:rest
loopback-connector-rest/lib/rest-model.js loopback:connector:rest
loopback-connector-rest/lib/swagger-client.js loopback:connector:rest:swagger
loopback-connector-soap/lib/soap-connector.js loopback:connector:soap
strong-remoting
strong-remoting/lib/dynamic.js strong-remoting:dynamic
strong-remoting/lib/exports-helper.js strong-remoting:exports-helper
strong-remoting/lib/http-context.js strong-remoting:http-context
strong-remoting/lib/http-invocation.js strong-remoting:http-invocation
strong-remoting/lib/jsonrpc-adapter.js strong-remoting:jsonrpc-adapter
strong-remoting/lib/remote-objects.js strong-remoting:remotes
strong-remoting/lib/rest-adapter.js strong-remoting:rest-adapter
strong-remoting/lib/shared-class.js strong-remoting:shared-class
strong-remoting/lib/shared-method.js strong-remoting:shared-method
strong-remoting/lib/socket-io-adapter.js strong-remoting:socket-io-adapter
strong-remoting/lib/socket-io-context.js strong-remoting:socket-io-context
loopback-explorer
loopback-explorer/lib/route-helper.js loopback:explorer:routeHelpers
loopback-workspace
loopback-workspace/connector.js workspace:connector
loopback-workspace/connector.js workspace:connector:save-sync
loopback-workspace/models/config-file.js workspace:config-file
loopback-workspace/models/definition.js workspace:definition
loopback-workspace/models/facet.js workspace:facet
loopback-workspace/models/facet.js: var workspace:facet:load: - facetName
loopback-workspace/models/facet.js: var workspace:facet:save: - facetName
loopback-workspace/models/workspace.js workspace