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.”

Logging

Focus mode
Logging - AWS SDK for Go v2

The AWS SDK for Go has logging facilities available that allow your application to enable debugging information for debugging and diagnosing request issues or failures. The Logger interface and ClientLogMode are the main components available to you for determining how and what should be logged by clients.

Logger

When constructing an Config using LoadDefaultConfig a default Logger is configured to send log messages to the process' standard error (stderr). A custom logger that satisfies the Logger interface can be passed as an argument to LoadDefaultConfig by wrapping it with config.WithLogger.

For example, to configure our clients to use our applicationLogger:

cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithLogger(applicationLogger))

Now clients configured using the constructed aws.Config will send log messages to applicationLogger.

Context-Aware Loggers

A Logger implementation may implement the optional ContextLogger interface. Loggers that implement this interface will have their WithContext methods invoked with the current context. This allows your logging implementations to return a new Logger that can write additional logging metadata based on values present in the context.

ClientLogMode

By default, service clients do not produce log messages. To configure clients to send log messages for debugging purposes, use the ClientLogMode member on Config. ClientLogMode can be set to enable debugging messaging for:

  • Signature Version 4 (SigV4) Signing

  • Request Retries

  • HTTP Requests

  • HTTP Responses

For example, to enable logging of HTTP requests and retries:

cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithClientLogMode(aws.LogRetries | aws.LogRequest))

See ClientLogMode for the different client log modes available.

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.