[AWS Javascript SDK V3] How to activate debug log?

0

The answer here: https://repost.aws/knowledge-center/sqs-queuedoesnotexist-errors says (in the Incorrect Region section) "You can also verify the Region of the request by activating the debug log on the SDK or AWS CLI. Debug logs show the destination host for the request."

How do I activate the debug log for the AWS Javascript SDK v3? Could someone please point out the relevant documentation? I looked in https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/ and https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/welcome.html and failed to find relevant sections.

ack_inc
질문됨 일 년 전3433회 조회
2개 답변
0

I'm using below sample code to log the verbose information of AWS JS SDK v3.

import { DescribeParametersCommand, SSMClient } from "@aws-sdk/client-ssm";
import * as log4js from "log4js";

log4js.configure({
  appenders: { cheese: { type: "file", filename: "cheese.log" } },
  categories: { default: { appenders: ["cheese"], level: "error" } },
});

const logger = log4js.getLogger();
logger.level = "debug";

async function main() {
  const ssmClient = new SSMClient({
    logger: logger,
  });
  const parameters = await ssmClient.send(new DescribeParametersCommand({}));
  console.log(parameters);
}

Update on 11/2: A blog post with working code snippet

profile picture
Kane
답변함 일 년 전
-1

Hi there,

Thank you for reaching out to us.

  1. Please check this link to enable Logging AWS SDK for JavaScript Calls. (Version 2)

https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/logging-sdk-calls.html

To turn on the logger and print log entries in the console, add the following statement to your code. [ AWS.config.logger = console; ]

  1. Please check this link to enable Logging AWS SDK for JavaScript Calls. (Version 3)

https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/interfaces/_aws_sdk_types.logger-1.html#debug https://github.com/aws/aws-sdk-js-v3/blob/e77e1150/packages/types/src/logger.ts#L31

  1. For AWS CLI, you can add " --debug " at the end of the command as well. [Check the example on the link below]

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-troubleshooting.html#general-debug

I hope this helps! Thank you!

Have A Nice Day!

AWS
지원 엔지니어
Sagar_T
답변함 일 년 전
  • The step 2 for SDK v3, the link is about to the logger utility of SDK library, not it's a doc about how enabling debugging log of SDK itself.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠