Export (0) Print
Expand All

Set Log Sink Levels (XML)

Microsoft project code named "Velocity" offers the option to configure log sinks on both the server and client sides. On the server side, log sinks can only be configured in the cache host configuration file. On the client side, there are two options. You can configure log sinks in the application configuration file or you can do it programmatically.

The following procedures describe how to enable log sinks in the XML-based configuration files of the cache client. For more information about how to configure log sinks programmatically, see Set Log Sink Levels.

noteNote
The XML settings required to enable log sinks on the cache host are the same as on the cache client. By default, the cache host already has some log sinks explicitly defined. Because a fabric element is already present on the cache host, the following step-by-step procedures to prepare log sink settings on the cache client are not identical.

In the cache client or host configuration file, the log sink settings are defined in the fabric element. The fabric element is a child of the configuration element and must always be positioned after the configSections element. For more information about log sink settings, see Log Sink Settings (Velocity).

These procedures assume that you have already prepared your development environment and set references to the "Velocity" assemblies, and so on. For more information, see Prepare the Development Environment.

Data in the cache is not encrypted and is available to any cache client with the appropriate configuration settings. We highly recommend that you secure the XML-based application configuration files used to specify the cache client.

To set log sinks in the cache client application configuration file

  1. Create the application configuration file and configure the cache client as a routing or simple client. For more information, see Get Started with a Routing Client (XML) or Get Started with a Simple Client (XML).

  2. Verify that there is a section element in the configSections of the application configuration file that specifies the fabric element. The "Velocity" assemblies need this in order to read the fabric element. If not present, insert the following section element: <section name="fabric" type="System.Data.Fabric.Common.ConfigFile, FabricCommon" allowLocation="true" allowDefinition="Everywhere"/>

  3. Copy the fabric element from the example later in this topic into your configuration file. Place it in the configuration element after the configSections element.

  4. If you want to enable a console-based log sink, set the defaultLevel attribute to a value between 0 and 3 in the customType element used to define the console sink. Setting the defaultLevel to a value of -1 disables the log sink.

  5. If you want to enable a file-based log sink, set the defaultLevel attribute to a value between 0 and 3 in the customType element used to define the file sink. Setting the defaultLevel to a value of -1 disables the file sink.

  6. (Optional) If desired, change the log file naming convention and storage location by editing the sinkParam attribute of customType element used to define the file sink. For more information about the file naming convention, see Log Sink Settings.

  7. If you want to enable an Event Tracing for Windows (ETW)-based log sink, set the defaultLevel attribute to a value between 0 and 3 in the customType element used to define the ETW-based log sink. Setting the defaultLevel to a value of -1 disables the ETW-based log sink.

  8. For the log sinks to take effect on the cache host, use PowerShell to restart the cache host. For more information about the cache administration cmdlets, see Cache Administration with Windows PowerShell.

Example

This example shows a fabric element that you can use to enable logging on your cache client or cache host.

Paste this element to the configuration file of your cache client or cache host. Be sure to position it in the configuration element after the configSections element. Then set the defaultLevel attributes to meet your tracing needs. The following example has all log sinks configured to be disabled.

To configure log sinks on the cache host, the same customType elements can be used in the file that is named DistributedCache.exe.config. Note that the cache host already has a fabric element that has more section elements than are needed on the client. On the cache host, customType elements are already present for console and ETW-based log sinks. To explicitly configure a file-based log sink on the cache host, copy the file-based log sink customType element from the following example and paste it next to the other customType elements.

<fabric>
  <section name="logging" path="">    
  <!--log sink configuration-->
  <collection name="sinks" collectionType="list">
    
    <!-- disabled console-based log sink -->
    <customType 
      className="System.Data.Fabric.Common.EventLogger,FabricCommon"
      sinkName="System.Data.Fabric.Common.ConsoleSink,FabricCommon" 
      sinkParam="" 
      defaultLevel="-1" />
    
    <!--disabled file-based log sink-->
    <customType 
      className="System.Data.Fabric.Common.EventLogger,FabricCommon" 
      sinkName="System.Data.Fabric.Common.FileEventSink,FabricCommon" 
      sinkParam="Dcache/dd-hh-mm" 
      defaultLevel="-1" />
    
    <!--disabled ETW-based sink -->
    <customType 
      className="System.Data.Fabric.Common.EventLogger,FabricCommon" 
      sinkName="Microsoft.Data.Caching.ETWSink, CacheBaseLibrary" 
      sinkParam="" 
      defaultLevel="-1" />
    
  </collection>
  </section>
</fabric>

See Also

Show:
© 2014 Microsoft