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?False
Position?2
Accept pipeline input?True (ByPropertyName)
-Name <String>
The name of the logger.
Required?False
Position?1
Accept pipeline input?True (ByPropertyName)
-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?True (ByPropertyName)
-TraceListener <TraceListener>
Specify a custom trace listener object.
Required?False
Position?1
Accept pipeline input?True (ByPropertyName)

Outputs

None
This cmdlet does not produce any output.

Examples

Example 1

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

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