Would you like to contribute to the Titanium docs? To get started, sign up for an account on the Appcelerator Wiki and sign our CLA.

Skip to end of metadata
Go to start of metadata

Logger API

The logger class lets you add custom messages to the application log, in addition to the ones generated automatically by . For published applications, custom log messages appear in the output of the loglist and logcat commands. When running your application locally (via the appc cloud run command, they are displayed in the local console.


In productions, you may want to minimize output logs to improve application performance and reduce memory consumption.


First, require the logger class:

Set the desired log level by calling the setLevel() method:

Call one of the logging methods

For published applications, log messages are displayed by the output of the appc cloud loglist and appc cloud logcat commands, for example: 

When running your application locally via the acs run command log messages are displayed in the console.

Specifying application log level

To set the log level, you call logger.setLevel() and pass it one of the following log level strings, in ascending order of log detail:

  • "OFF" — Disables log generation.
  • "FATAL"
  • "ERROR"
  • "WARN"
  • "INFO"
  • "DEBUG"
  • "TRACE"
  • "ALL" — Includes output from all log methods.

The current log level determines which log method output is included in the log output. For example, if you set the log level to "WARN", only messages logged by logger.fatal()logger.error(), or logger.warn() methods will be included in the log: 

To include messages from all log methods, set the log level to "ALL":

To disable log generation entirely, set the log level to "OFF"

The default log level is "DEBUG", if not specified.

Logging methods

To log a message, call one of the following methods, passing it the string to output. The logging level must be set to an appropriate level.

  • logger.fatal(<message>) — Output only when log level is set to "FATAL" or "ALL".
  • logger.error(<message>) — Output only when log level is set to "FATAL""ERROR", or "ALL".
  • logger.warn(<message>) — Output only when log level is set to "FATAL""ERROR""WARN", or "ALL".
  • logger.info(<message>) — Output only when log level is set to "FATAL""ERROR""WARN""INFO", or "ALL"
  • logger.debug(<message>) — Output only when log level is set to "FATAL""ERROR""WARN""INFO""DEBUG", or "ALL".
  • logger.trace(<message>) — Output only when log level is set to "FATAL""ERROR""WARN""INFO""DEBUG""TRACE", or "ALL".
  • No labels