Getting Started With .NET NuGet Package

If you have made it here chances are you have installed Unified Logging NuGet package.  If not, open up the NuGet package manager and search for “UnifiedLogging”.

Now that you have a reference to the client assembly you are ready to use the trace listener that is contained within it.

It is no accident that this package does not mess with your configuration, this is because different logging frameworks can be used.  First you must visit the Profile page and grab your Access Key and Secret Key.

Here are examples for you to use:

.NET Tracing – Notice the use of the EventTypeFilter:
<system.diagnostics>
    <trace autoflush=”true” indentsize=”4″>
      <listeners>
        <clear/>
        <add name=”UnifiedLoggingListener”
             type=”UnifiedLogging.Client.ULListener, UnifiedLogging.Client”
             initializeData=”AccessKey=[AccessKey], SecretKey=[SecretKey], SubmissionUrl=https://data.unifiedlogging.com/ulmessages/” >
          <filter type=”System.Diagnostics.EventTypeFilter” initializeData=”Error”/>
        </add>
      </listeners>
    </trace>
  </system.diagnostics>

Enterprise Library – in the loggingConfiguration listeners section:
<add listenerDataType=”Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.SystemDiagnosticsTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″
 type=”UnifiedLogging.Client.ULListener, UnifiedLogging.Client”
 traceOutputOptions=”None” filter=”All” name=”ULListener” initializeData=”AccessKey=[AccessKey], SecretKey=[SecretKey], SubmissionUrl=https://data.unifiedlogging.com/ulmessages/” />

By adding one of the above to your configuration you will now be sending information to Unified Logging.

This assembly also contains supporting classes like the ULSubmitDataRequest which would allow one to submit data to Unified Logging and is used by the trace listener.
There is also a FailedRequestQueue which is used by the trace listener, when a request fails it will be retried every 30 seconds.  This queue is in memory and by default holds 100 messages.  The number of messages the FailedRequestQueue will hold can be set in the initialize data by setting the FailedQueueMax.

Example Showing .NET Tracing:
<system.diagnostics>
    <trace autoflush=”true” indentsize=”4″>
      <listeners>
        <clear/>
        <add name=”UnifiedLoggingListener”
             type=”UnifiedLogging.Client.ULListener, UnifiedLogging.Client”
             initializeData=”AccessKey=[AccessKey], SecretKey=[SecretKey], SubmissionUrl=https://data.unifiedlogging.com/ulmessages/, FailedQueueMax=5” >
          <filter type=”System.Diagnostics.EventTypeFilter” initializeData=”Error”/>
        </add>
      </listeners>
    </trace>
  </system.diagnostics>

NEXT STEP: Learn About Indexes

Comments are closed.