AWS SDK for .NET Documentation
DynamoDBTraceListener Class
AmazonAmazon.TraceListenerDynamoDBTraceListener Did this page help you?   Yes   No    Tell us about it...

DynamoDBTraceListener is a custom TraceListener that logs events to a DynamoDB table. The listener can be configured through the application's .config file or by instantiating an instance of DynamoDBTraceListener and setting the Configuration property on the instance.

The target table must have a string hash key and a string range key. If the table does not exist the listener will create it during initialization with default read and write units set to 1 and 10, respectively, unless configured otherwise.

While DynamoDBTraceListener is running, it will write temporary log files into current directory. These log files will be deleted once the data is pushed to DynamoDB. The logs are pushed to DynamoDB under the following conditions: 1. Flush is called on the DynamoDBTraceListener 2. Close is called on the DynamoDBTraceListener 3. WritePeriod has elapsed since last write (If the listener is used with the SDK clients, Flush is invoked when the client is disposed.) If the application exits and there are still log files (in the event Flush is not invoked or the application terminates unexpectedly), these log files will be pushed to DynamoDB on the next execution of the application. Log files can also be flushed manually by creating an instance of DynamoDBTraceListener and using the FlushLog method on a particular log file.

Example of an app.config entry setting up the listener with all possible configurations specified:

CopyC#
<system.diagnostics>
  <trace>
    <listeners>
      <add name="dynamo" type="Amazon.Logging.DynamoDBTraceListener, AWS.Extensions"
            AWSAccessKey="YOUR_ACCESS_KEY"
            AWSSecretKey="YOUR_SECRET_KEY"
            Region="us-west-2"
            Table="Logs"
            CreateIfNotExist="true"
            ReadCapacityUnits="1"
            WriteCapacityUnits="10"
            HashKey="Origin"
            RangeKey="Timestamp"
            MaxLength="10000"
            ExcludeAttributes="Callstack, Host"
            HashKeyFormat="{Host}-{EventType}-{ProcessId}"
            RangeKeyFormat="{Time}"
            WritePeriodMs="60000"
            LogFilesDir="C:\Logs"
        />
    </listeners>
  </trace>
</system.diagnostics>

Declaration Syntax
C#
public class DynamoDBTraceListener : TraceListener
Members
All MembersConstructorsMethodsProperties



IconMemberDescription
DynamoDBTraceListener()()()()
Constructs an instance of the DynamoDBTraceListener.

DynamoDBTraceListener(String)
Constructs a named instance of the DynamoDBTraceListener.

Attributes
Gets the custom trace listener attributes defined in the application configuration file.
(Inherited from TraceListener.)
Close()()()() (Overrides TraceListener.Close()()()().)
Configuration
Current configuration.

CreateObjRef(Type)
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.)
Dispose()()()()
Releases all resources used by the TraceListener.
(Inherited from TraceListener.)
Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Fail(String)
Emits an error message to the listener you create when you implement the TraceListener class.
(Inherited from TraceListener.)
Fail(String, String)
Emits an error message and a detailed error message to the listener you create when you implement the TraceListener class.
(Inherited from TraceListener.)
Filter
Gets and sets the trace filter for the trace listener.
(Inherited from TraceListener.)
Flush()()()() (Overrides TraceListener.Flush()()()().)
FlushLog(String)
Flushes an existing log to DynamoDB, then deletes/empties the log file. This method can be invoked manually to flush left-over log files.

GetHashCode()()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetLifetimeService()()()()
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
GetType()()()()
Gets the type of the current instance.
(Inherited from Object.)
IndentLevel
Gets or sets the indent level.
(Inherited from TraceListener.)
IndentSize
Gets or sets the number of spaces in an indent.
(Inherited from TraceListener.)
InitializeLifetimeService()()()()
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
IsEnabled
Whether the DynamoDBTraceListener is enabled. Read-only field that is set to false if the listener is disabled. The listener can be disabled if initialization has failed (in which case an error will be logged to the event log) or the listener was closed.

IsThreadSafe (Overrides TraceListener.IsThreadSafe.)
Name
Gets or sets a name for this TraceListener.
(Inherited from TraceListener.)
ToString()()()()
Returns a string that represents the current object.
(Inherited from Object.)
TraceData(TraceEventCache, String, TraceEventType, Int32, Object) (Overrides TraceListener.TraceData(TraceEventCache, String, TraceEventType, Int32, Object).)
TraceData(TraceEventCache, String, TraceEventType, Int32, array<Object>[]()[][]) (Overrides TraceListener.TraceData(TraceEventCache, String, TraceEventType, Int32, array<Object>[]()[][]).)
TraceEvent(TraceEventCache, String, TraceEventType, Int32) (Overrides TraceListener.TraceEvent(TraceEventCache, String, TraceEventType, Int32).)
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, array<Object>[]()[][]) (Overrides TraceListener.TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, array<Object>[]()[][]).)
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String) (Overrides TraceListener.TraceEvent(TraceEventCache, String, TraceEventType, Int32, String).)
TraceOutputOptions
Gets or sets the trace output options.
(Inherited from TraceListener.)
TraceTransfer(TraceEventCache, String, Int32, String, Guid) (Overrides TraceListener.TraceTransfer(TraceEventCache, String, Int32, String, Guid).)
Write(String) (Overrides TraceListener.Write(String).)
Write(Object)
Writes the value of the object's ToString()()()() method to the listener you create when you implement the TraceListener class.
(Inherited from TraceListener.)
Write(String, String)
Writes a category name and a message to the listener you create when you implement the TraceListener class.
(Inherited from TraceListener.)
Write(Object, String)
Writes a category name and the value of the object's ToString()()()() method to the listener you create when you implement the TraceListener class.
(Inherited from TraceListener.)
WriteLine(String) (Overrides TraceListener.WriteLine(String).)
WriteLine(Object)
Writes the value of the object's ToString()()()() method to the listener you create when you implement the TraceListener class, followed by a line terminator.
(Inherited from TraceListener.)
WriteLine(String, String)
Writes a category name and a message to the listener you create when you implement the TraceListener class, followed by a line terminator.
(Inherited from TraceListener.)
WriteLine(Object, String)
Writes a category name and the value of the object's ToString()()()() method to the listener you create when you implement the TraceListener class, followed by a line terminator.
(Inherited from TraceListener.)
Inheritance Hierarchy
Object
MarshalByRefObject
 TraceListener
  DynamoDBTraceListener

Assembly: AWS.TraceListener (Module: AWS.TraceListener) Version: 1.0.0.0 (1.0.0.0)