Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 29, 2024

Console Logger

AWS Amplify writes console logs through Logger. You can use Logger in your apps for the same purpose.

Installation

Import Logger:

import { Logger } from 'aws-amplify';

Working with the API

You can call logger for different console message modes:

const logger = new Logger('foo');
logger.info('info bar');
logger.debug('debug bar');
logger.warn('warn bar');
logger.error('error bar');

When handling an error:

try {
// ...
} catch(e) {
logger.error('error happened', e);
}

Setting Logging Levels

You can set a log level when you create your logger instance:

const logger = new Logger('foo', 'INFO');
logger.debug('callback data', data); // this will not write the message

Global logger configuration will override your logger instance's configuration:

Amplify.Logger.LOG_LEVEL = 'DEBUG';
const logger = new Logger('foo', 'INFO');
logger.debug('callback data', data); // this will write the message since the global log level is 'DEBUG'

During web development, you can set global log level in browser console log:

window.LOG_LEVEL = 'DEBUG';

Supported log levels:

  • ERROR
  • WARN
  • INFO
  • DEBUG
  • VERBOSE