Partager via


Azure Table Storage event sink

patterns & practices Developer Center

The WindowsAzureTableSink class is defined in the Microsoft.Practices.EnterpriseLibrary.SemanticLogging.WindowsAzure.Sinks namespace. It is included in the Semantic Logging Application Block – Azure Sink package obtainable from NuGet.

The name of the extension method used to create a sink and subscribe it to an event listener is LogToWindowsAzureTable.

The method CreateListener in the WindowsAzureTableLog class creates an observable listener and a WindowsAzureTableSink instance, and subscribes the sink to the listener.

The following table describes the parameters of the LogToWindowsAzureTable and CreateListener methods. If you are using the application block out-of-process, you set these parameters using the configuration file for the Out-of-Process Host. See Configuration schema for the out-of-process model for details.

Parameter

Description

instanceName

The name of the instance originating the log entries. This name must be unique for each instance of the application.

connectionString

The connection string for the Azure storage account you are using. This is required. The format is DefaultEndpointsProtocol=https;AccountName=AccountName;AccountKey=AccountKeyfor an Azure storage account, or UseDevelopmentStorage=true if you are storing entries in the local Azure Storage Emulator during development and testing.

tableAddress

The name of the table you will write log messages to. The default value is SLABLogsTable.

bufferInterval

This optional Timespan parameter controls how frequently the sink writes the accumulated log messages to Azure table storage. By default, the sink buffers log messages for 10 seconds.

maxBufferSize

This optional parameter defines the maximum number of entries that can be buffered while the sink is writing to Azure table storage, before it starts dropping entries. The default value is 30,000 entries.

onCompletedTimeout

Defines a timeout interval for flushing the entries after an OnCompleted call is received, and before disposing the sink. This means that if the timeout period elapses, some event entries will be dropped and not sent to the store. Normally, calling IDisposable.Dispose on the System.Diagnostics.Tracing.EventListener will block until all the entries are flushed or the interval elapses. If null is specified, then the call will block indefinitely until the flush operation finishes.

sortKeysAscending

This optional Boolean parameter controls the sort order of the log messages in the Azure table. The default value is false, which causes the log messages to be sorted in reverse date/time order so that the most recent entries appear first in the table.

Notes

  • The Azure Table Storage event sink can buffer log messages for a configurable period. This maximizes performance because the sink typically communicates over the network with the service that is ultimately responsible for persisting the log messages from your application. Buffering improves performance—“chunky” (instead of “chatty”) communication over a network typically improves the overall throughput.
  • Buffering introduces a trade-off. If the process that is buffering the messages crashes before delivering the messages, you lose those messages. The shorter the buffering period, the fewer messages you will lose in the event of an application crash, but at the cost of a reduced throughput of log messages.
  • The buffering in this sink uses an Azure storage transaction that is limited to 4 MB of data. The sink will automatically avoid sending all buffered events if that would exceed the transaction limit by separating them into multiple transactions.

The following table shows the information that is output by the Azure Table Storage event sink.

Column

Description

PartitionKey

The partition key for the Azure storage table.

RowKey

The RowKey is determined by the value of the sortKeysAscending parameter of the event sink. For more information, see the Notes that precede this table.

Timestamp

A timestamp that records when the log message was written to Azure table storage.

EventId

A unique identifier for this event type. This id is specified using the EventId property of the Event attribute that decorates the log method in your custom event source.

EventDate

A timestamp that records when the log message was written by the event source.

Keywords

An integer value that represents the value of the Keywords property of the Event attribute that decorates the log method in your custom event source. If multiple Keywords are assigned to a log method, this value represents the result of an OR of the keyword values.

EventSourceGuid

A unique identifier for the event source that logged the message.

EventSourceName

The name of the event source as specified using the EventSource attribute in the custom event source class.

InstanceName

The name of the instance sending the events. You specify this when you create the event sink.

Level

The integer value of the Level property of the Event attribute that decorates the log method in your custom event source. See EventLevel Enumeration on MSDN.

Message

This is the formatted message written to the log. It is the value of the Message property of the Event attribute that decorates your log messages in your custom event source, with the placeholders replaced by values from the event payload.

Opcode

The integer value of the Opcode property of the Event attribute that decorates the log method in your custom event source. Valid values are defined by the EventOpcode enumeration.

Task

A task identifier. You can optionally assign task identifiers to the log messages in your custom event source by using the Task property of the Event attribute that decorates the log method in your event source.

Version

A version number. You can optionally assign a version number to the log messages in your custom event source by using the Version property of the Event attribute that decorates the log method in your event source.

ProcessId

The identifier assigned to the process where the event was raised. This value is a nullable Integer. It is available only when the application is running in full trust mode.

ThreadId

The identifier assigned to the thread that raised this event. This value is a nullable Integer. It is available only when the application is running in full trust mode.

ActivityId

A GUID identifier for the current activity in the process for which the event is involved.

RelatedActivityId

A GUID identifier for a related activity in a different process that is related to the current process.

Payload

The parameter values passed to the custom log method in your custom event source. These are displayed in JSON format. Any custom log methods that have no parameters will show “{}”.

PayloadXX

Custom columns such as PayloadID and Payloadurl that contain individual payload values.

Next Topic | Previous Topic | Home | Community