Name:
interface
Value:
Extend your Amplify Gen 2 app with AWS Blocks — self-contained backend capabilities you compose into your existing backend.

Page updated Apr 29, 2024

NewDeploy web apps with Git or your AI coding agent using the latest AWS Amplify. Add managed databases and authentication as you grow. Explore the documentation.
Maintenance ModeYou are viewing Amplify Gen 1 documentation. Amplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027. For existing Gen 1 projects, a migration guide and tooling are available to help you upgrade.
JavaScript v5Amplify JavaScript v5 has entered maintenance mode. We recommend upgrading to v6. A migration guide is available to help you upgrade from v5 to v6.

Console Logger

These docs cover Amplify Gen 1. For new web apps, we recommend the latest AWS Amplify, with a simplified CLI and native integrations for databases, storage, and AI models. Get started with the latest AWS Amplify.

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