Logging

This section provides information on API Builder logging components. API Builder streams log messages to the console, enabling integration with third-party log aggregation tools. For additional information on integrating API Builder logging with a third-party log aggregation tool, refer to Export API Builder Logs into a Data Store.

Configure logging

The logLevel can be set in the configuration. See Project Configuration.

Logger programmatic interface

The Logger interface allows you to log directly from the API Builder programmatic interface.

Static properties

  • DEBUG:  (Number) - Constant indicating the debug level.
  • ERROR:  (Number) - Constant indicating the error level.
  • FATAL: (Number)  Constant indicating the fatal level.
  • INFO:  (Number) - Constant indicating the info level.
  • TRACE:  (Number) - Constant indicating the trace level.
  • WARN: (Number) - Constant indicating the warn level.
  • NONE: (Number) - Constant indicating the none level.

Instance methods

  • debug[params] ) : Logs a message with a debug-level severity.  If no arguments are passed, returns a boolean indicating if the debug level is enabled.
  • error[params] ) : Logs a message with an error-level severity. I f no arguments are passed, returns a boolean indicating if the error level is enabled.
  • fatal[params] ) : Logs a message with a fatal-level severity.  If no arguments are passed, returns a boolean indicating if the fatal level is enabled.
  • info[params] ) : Logs a message with an info-level severity.  If no arguments are passed, returns a boolean indicating if the info level is enabled.
  • level[level] ) : Sets or retrieves the log level. 
  • levels[stream], [level] ) : Sets or retrieves the log level for a specific stream.  If no arguments are passed, retrieves an array of available log levels. If the stream is passed, retrieves the current log level of the stream.
  • stripColors string ): Removes ANSI color codes from the string.
  • trace[params] ) : Logs a message with a trace-level severity.  If no arguments are passed, returns a boolean indicating if the trace level is enabled.
  • warn[params] ) : Logs a message with a warn-level severity.  If no arguments are passed, returns a boolean indicating if the warning level is enabled.

Static methods

  • createDefaultLoggeroptions ) : Creates a log utility instance.
  • createLoggeroptions ) : Creates a log utility instance.
  • createRestifyLoggerAPI, options ) : Creates a restify version of the log utility.

Logs format

The API Builder logs use the JSON logging utility.

All logs are listed in the console each time you run your APP.

The Request/Response Logs have a specific format (for example ID, Name, and Data ).

Related Links