A trace listener designed to run on an on-premesis machine, which will write trace information in batches to a table in Windows Azure Table Storage.
From NuGet:
PM> Install-Package Two10.AzureTraceListener
Clone from GitHub:
> git clone https://github.com/richorama/Two10.AzureTraceListener.git
Then open the solution in Visual Studio and build.
-
Add a reference to the
Two10.AzureTraceListenerassembly in your project. -
Update your App.config to set up the trace listener:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace>
<listeners>
<add name="TableTraceListener"
type="Two10.AzureTraceListener.TableTraceListener, Two10.AzureTraceListener"
connectionString="UseDevelopmentStorage=true"
tableName="MyTraceTable" />
<remove name="Default"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>You should set the connectionString value to be the connection string of your Windows Azure Storage Account.
Note:
tableNameis optional, and will default totrace.
- Write to
Tracein your application:
System.Diagnostics.Trace.WriteLine("Hello World");The Trace Listener will periodically (every minute) write any trace information to your table, with the message in a Value column.
The PartitionKey is comprised of the machine name and the date:
MACHINENAME-YYYY-MM-DD
The RowKey is the remaining ticks in the epoch, therefore more recent records are written last.
Example records:
| PartitionKey | RowKey | Timestamp | Value |
|---|---|---|---|
| DISCOVERY-2014-03-21 | 2520068972872977706 | 2014-03-21T12:05:15.102Z | Trace message at 21/03/2014 12:05:12 |
| DISCOVERY-2014-03-21 | 2520068972882984955 | 2014-03-21T12:05:15.102Z | Trace message at 21/03/2014 12:05:11 |
If a category is supplied, this will also be recorded in the table.
The Two10.AzureTraceListener.TraceEntity class can be used to query the table.
MIT