C# 클래스 Amazon.TraceListener.DynamoDBTraceListener

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: <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>

상속: System.Diagnostics.TraceListener
파일 보기 프로젝트 열기: scopely/aws-sdk-net

Private Properties

프로퍼티 타입 설명
AppendDocument void
ComposeMessage string
CreateTable Amazon.DynamoDBv2.DocumentModel.Table
DeleteLogFile void
DisableListener void
EnsureWriter bool
ExpandVariables string
GetAttribute string
GetAttributeAsBool bool
GetAttributeAsInt int
GetConfigFromAttributes Configs
GetCurrentTimestamp System.DateTime
GetDocuments IEnumerable
GetNewLogFilePath string
Init void
IsLogFileEmpty bool
LimitLength string
Log void
TimedWriter void
WriteEventLogMessage void

공개 메소드들

메소드 설명
Close ( ) : void
DynamoDBTraceListener ( ) : System

Constructs an instance of the DynamoDBTraceListener.

DynamoDBTraceListener ( string name ) : System

Constructs a named instance of the DynamoDBTraceListener.

Flush ( ) : void
FlushLog ( string log ) : void

Flushes an existing log to DynamoDB, then deletes/empties the log file. This method can be invoked manually to flush left-over log files.

TraceData ( TraceEventCache eventCache, string source, TraceEventType eventType, int id ) : void
TraceData ( TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data ) : void
TraceEvent ( TraceEventCache eventCache, string source, TraceEventType eventType, int id ) : void
TraceEvent ( TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format ) : void
TraceTransfer ( TraceEventCache eventCache, string source, int id, string message, System.Guid relatedActivityId ) : void
Write ( string message ) : void
WriteLine ( string message ) : void

보호된 메소드들

메소드 설명
Dispose ( bool disposing ) : void

Implements the Dispose pattern for the AmazonWebServiceClient

GetSupportedAttributes ( ) : string[]
WriteIndent ( ) : void

비공개 메소드들

메소드 설명
AppendDocument ( Document doc ) : void
ComposeMessage ( object data ) : string
CreateTable ( ) : Table
DeleteLogFile ( string path ) : void
DisableListener ( string message ) : void
EnsureWriter ( ) : bool
ExpandVariables ( string value, Document doc ) : string
GetAttribute ( string name, string defaultValue = "" ) : string
GetAttributeAsBool ( string name, bool defaultValue = false ) : bool
GetAttributeAsInt ( string name, int defaultValue = -1 ) : int
GetConfigFromAttributes ( ) : Configs
GetCurrentTimestamp ( ) : System.DateTime
GetDocuments ( string path ) : IEnumerable
GetNewLogFilePath ( ) : string
Init ( ) : void
IsLogFileEmpty ( string path ) : bool
LimitLength ( string value ) : string
Log ( TraceEventCache eventCache, string source, TraceEventType eventType, int eventId ) : void
TimedWriter ( object sender, System e ) : void
WriteEventLogMessage ( string message, EventLogEntryType logEntryType ) : void

메소드 상세

Close() 공개 메소드

public Close ( ) : void
리턴 void

Dispose() 보호된 메소드

Implements the Dispose pattern for the AmazonWebServiceClient
protected Dispose ( bool disposing ) : void
disposing bool Whether this object is being disposed via a call to Dispose /// or garbage collected.
리턴 void

DynamoDBTraceListener() 공개 메소드

Constructs an instance of the DynamoDBTraceListener.
public DynamoDBTraceListener ( ) : System
리턴 System

DynamoDBTraceListener() 공개 메소드

Constructs a named instance of the DynamoDBTraceListener.
public DynamoDBTraceListener ( string name ) : System
name string
리턴 System

Flush() 공개 메소드

public Flush ( ) : void
리턴 void

FlushLog() 공개 메소드

Flushes an existing log to DynamoDB, then deletes/empties the log file. This method can be invoked manually to flush left-over log files.
public FlushLog ( string log ) : void
log string
리턴 void

GetSupportedAttributes() 보호된 메소드

protected GetSupportedAttributes ( ) : string[]
리턴 string[]

TraceData() 공개 메소드

public TraceData ( TraceEventCache eventCache, string source, TraceEventType eventType, int id ) : void
eventCache System.Diagnostics.TraceEventCache
source string
eventType TraceEventType
id int
리턴 void

TraceData() 공개 메소드

public TraceData ( TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data ) : void
eventCache System.Diagnostics.TraceEventCache
source string
eventType TraceEventType
id int
data object
리턴 void

TraceEvent() 공개 메소드

public TraceEvent ( TraceEventCache eventCache, string source, TraceEventType eventType, int id ) : void
eventCache System.Diagnostics.TraceEventCache
source string
eventType TraceEventType
id int
리턴 void

TraceEvent() 공개 메소드

public TraceEvent ( TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format ) : void
eventCache System.Diagnostics.TraceEventCache
source string
eventType TraceEventType
id int
format string
리턴 void

TraceTransfer() 공개 메소드

public TraceTransfer ( TraceEventCache eventCache, string source, int id, string message, System.Guid relatedActivityId ) : void
eventCache System.Diagnostics.TraceEventCache
source string
id int
message string
relatedActivityId System.Guid
리턴 void

Write() 공개 메소드

public Write ( string message ) : void
message string
리턴 void

WriteIndent() 보호된 메소드

protected WriteIndent ( ) : void
리턴 void

WriteLine() 공개 메소드

public WriteLine ( string message ) : void
message string
리턴 void