Logging AWS SDK requests and responses
This feature allows you to add logging middleware to your AWS SDK client instances. It logs requests and responses, which is useful for debugging and monitoring purposes.
const { S3Client } = require('@aws-sdk/client-s3');
const { loggerMiddleware } = require('@aws-sdk/middleware-logger');
const { LogLevel } = require('@aws-sdk/types');
const client = new S3Client({});
client.middlewareStack.add(loggerMiddleware({ logLevel: LogLevel.INFO }), {
step: 'initialize',
name: 'loggerMiddleware',
tags: { LOGGER: 'LOGGER' },
});
// Now, when you make a request using the client, it will log the request and response.