Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn on wire logging in AWS SDK v3 for Node

How can I log the full HTTP request and response when using the AWS SDK v3 for Node / javascript?

like image 805
Rich Avatar asked Sep 02 '25 02:09

Rich


1 Answers

I was searching for a solution and this what I found:

const { RekognitionClient, ListFacesCommand } = require("@aws-sdk/client-rekognition");
const log4js = require("log4js");

log4js.configure({
  appenders: { out: { type: "stdout" } },
  categories: { default: { appenders: ["out"], level: "all" } },
});

const logger = log4js.getLogger();

const REGION = process.env.AWS_REGION;
const rkClient = new RekognitionClient({ region: REGION, logger: logger });

In my case, I use Rekognition, but you can use it for all services.

The endpoint is usally https://rekognition.<REGION>.amazonaws.com. See here: https://docs.aws.amazon.com/general/latest/gr/rande.html

To debug the call, you can use a proxy server (like fiddler). You can use CurrPorts with less info.

like image 150
Domus71 Avatar answered Sep 05 '25 23:09

Domus71