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

Below are static constant properties for programmatically setting the log level.  When set to a specific level, any log messages above that level, and below NONE will be logged.  For example, Logger.ERROR will only log ERROR and FATAL messages.

  • TRACE: (10)
  • DEBUG: (20)
  • INFO: (30)
  • WARN: (40)
  • ERROR: (50)
  • FATAL: (60)
  • NONE: (70)

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. If 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.
  • stripColors( string ): Removes ANSI color codes from the string (deprecated since 4.0).
  • 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

  • createDefaultLogger( options ): Creates a log utility instance.
  • createLogger( options ): Creates a log utility instance (deprecated since 4.0).
  • createRestifyLogger( apiBuilderInstance, options ): Creates a restify version of the log utility (deprecated since 4.0).

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