How to use “Velocity” logging framework
Microsoft project code named "Velocity" provides the ability to trace events on the cache client and cache host. These events are captured by enabling log sinks. A sink represents a valid destination to which logs or events can be emitted. “Velocity” supports three log sinks:
· Console sink - emits events to the console.
· File sink - emits events to a text file.
· ETW sink - emits events to the OS buffers which are written to the disk.
See related sections in the documentation for more details:
Log Sink Settings: http://msdn.microsoft.com/en-us/library/dd187434.aspx
How to: Set Log Sink Levels (XML): http://msdn.microsoft.com/en-us/library/dd169209.aspx
How to: Set Log Sink Levels (Code): http://msdn.microsoft.com/en-us/library/dd187351.aspx
How to change log file generation format
By default file sink emitted log files are generated hourly and use the following file format ‘dd-hh’. Hence you would see log files named with current date and hour and a new file would be generated every hour. For example, DCacheTrace13-2, DCacheTrace13-3, DCacheTrace13-4 and so on.
Now to increase or decrease the granularity of log file generation, you would need to change the above mentioned time format. Say for instance:
· If you need log files per minute, you would want to change it to ‘dd-hh-mm’.
· For a 24-hour format, change it to ‘dd-HH-mm’.
· For AM/PM display, change it to ‘dd-hh-mm tt’.
Now I will list out the steps required to change the time format. Note that these settings are applicable to a single cache host since changes are done locally.
· Open DistributedCache.exe.config (located in the installation folder).
· Go to <fabric> <section name=”logging” path=”” > tag.
· Add the following entry in “sinks” collection.
<customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.FileEventSink, FabricCommon" sinkParam="C:\Program Files\Microsoft Distributed Cache\V1.0\Logs\DCacheTrace[$]/dd-hh" defaultLevel="0" />
· The path in ‘sinkParam’ should be taken from ‘location’ attribute in the <log> tag.
· The portion after ‘/’ in ‘sinkParam’ represents the time format. Change it as per your requirements.
· Log level can be specified in ‘defaultLevel’. This represents the same property as ‘logLevel’ in the <log> tag.
· Note that these settings override the ones defined in the <log> tag.
For more details, refer to http://msdn.microsoft.com/en-us/library/dd187434.aspx
In the next post, I will talk about the ETW sink.
Amit Kumar Yadav
(Microsoft project code named “Velocity” team)