AWS Tools for Windows PowerShell
Command Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Synopsis

Adds a listener to aws service calls and enable logging.

Syntax

SimpleListener (Default)

Add-AWSLoggingListener
-Name <String>
-LogFilePath <String>
-Source <String>

CustomListener

Add-AWSLoggingListener
-TraceListener <TraceListener>
-Source <String>

Description

Adds a single trace listener to the specified trace source. Given a name and file path, creates a TextWriterTraceListener with the given name and file path, and adds it to the listeners for the trace source. If Source is not specified, 'Amazon' is assumed, which represents all SDK API calls. In the case where there are multiple listeners for multiple sources, Trace calls for an API will go to the most specific source only. For example, if one listener is added to 'Amazon.S3' and another on 'Amazon', then S3 calls will only be logged to the former listener.

Parameters

-LogFilePath <String>
File path to write the log to.
Required?True
Position?2
Accept pipeline input?False
-Name <String>
The name of the logger.
Required?True
Position?1
Accept pipeline input?False
-Source <String>
Specify a source to log responses for. Defaults to all responses (i.e. 'Amazon'). To limit to a specific service (for example DynamoDB), use 'Amazon.DynamoDB'.)
Required?False
Position?Named
Accept pipeline input?False
-TraceListener <TraceListener>
Specify a custom trace listener object.
Required?True
Position?1
Accept pipeline input?False

Inputs

This cmdlet does not accept pipeline input.

Outputs

None
This cmdlet does not produce any output.

Examples

Example 1

PS C:\>Add-AWSLoggingListener -Name MyAWSLogs -LogFilePath c:\logs\aws.txt
Attaches a listener for the source 'Amazon', matching responses from all services for the current script or shell. Log output will be written to the specified file (the folder path must exist). Multiple listeners for different namespaces can be active at a time. By default only error responses are logged.

Example 2

PS C:\>Add-AWSLoggingListener -Name MyS3Logs -LogFilePath c:\logs\s3.txt -Source Amazon.S3
Attaches a listener for the source 'Amazon.S3'. Responses matching only this namespace will be logged to the specified file (the folder path must exist). Multiple listeners for different namespaces can be active at a time. By default only error responses are logged.

Supported Version

AWS Tools for PowerShell: 2.x.y.z