Trace source associated with FileCache.
FileCache initializes Trace as follows:
Trace = new TraceSource(typeof(FileCache).FullName);
All operations performed by FileCache are then logged into this trace source. This is performed by calling Trace.TraceEvent
with the name of the operation and the item's key and region names. For instance, AddOrGetExisting will log the following standard .NET tracing:
Trace.TraceEvent(TraceEventType.Verbose, 1, "Set {0}.{1}", item.RegionName, item.Key);
The user can enable tracing in FileCache using the following:
// Create a disk file listener
string logFile = @"c:\log.txt";
TextWriterTraceListener trace = new TextWriterTraceListener(outFile);
trace.Name = "console";
// Add it to the FileCache trace listeners
Leadtools.Caching.FileCache.Trace.Listeners.Remove("Default");
Leadtools.Caching.FileCache.Trace.Listeners.Add(trace);
// Log everything
Leadtools.Caching.FileCache.Trace.Switch.Level = SourceLevels.All;
// Now use FileCache
FileCache fileCache = new FileCache();
// Use it ...
// Finally, stop tracing
trace.Flush();
Leadtools.Caching.FileCache.Trace.Listeners.Remove(trace);
trace.Dispose();