Capture Application Logs

Surface application logs and errors in LogRocket sessions

console

A collection of configuration options specific to console capture.

By default, LogRocket logs the following methods of the console API:

  • console.log()
  • console.info()
  • console.debug()
  • console.warn()
  • console.error()

LogRocket's console capture can be modified with the options below.

Disable Console Logging

isEnabled - Boolean

optional (default - true)

Disable this boolean to prevent logging of console data to LogRocket.

LogRocket.init(YOUR_APP_ID, {
  console: {
    isEnabled: false,
  },
});

You can also disable specific console methods by setting the method name to be false. By default, all methods will be logged unless explicitly set to false.

// This will log all console.info, console.warn, and console.error calls.
LogRocket.init(YOUR_APP_ID, {
  console: {
    isEnabled: {
      log: false,
      debug: false, 
    },
  },
});

Surface Console Errors in LogRocket

shouldAggregateConsoleErrors - Boolean

optional (default - false)

Use this option to control whether aggregated data about messages logged with console.error() or LogRocket.error() is surfaced as an error in LogRocket.

LogRocket.init(YOUR_APP_ID, {
  console: {
    shouldAggregateConsoleErrors: true,
  },
});