NET Caching Library Help
ClearLog(String) Method
Example 




KellermanSoftware.NetCachingLibrary Namespace > SmartCache Class > ClearLog Method : ClearLog(String) Method
Clear the file error log
Syntax
'Declaration
 
Public Overloads Function ClearLog( _
   ByVal filePath As System.String _
) As System.Boolean
'Usage
 
Dim instance As SmartCache
Dim filePath As System.String
Dim value As System.Boolean
 
value = instance.ClearLog(filePath)
public System.bool ClearLog( 
   System.string filePath
)
public: System.bool ClearLog( 
   System.string* filePath
) 
public:
System.bool ClearLog( 
   System.String^ filePath
) 

Parameters

filePath
Example
//Create a Primary Memory Cache with a backing File Cache
string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "KellermanSoftware", "NetCachingLibrary", "Tests");
SmartConfig config = new SmartConfig(new MemoryCacheProvider(), new FileCacheProvider(directory));
             
//Specify UserName and LicenseKey for Licensed Mode
//config.UserName = "my user name";
//config.LicenseKey = "my license key";
             
//Instantiate the cache
SmartCache cache = new SmartCache(config);
             
//Turn on throwing exceptions (the default is true)
cache.ThrowExceptions = true;
             
//Log to Console
cache.EnableLogging();
             
//Log to a File
string fileLogPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "KellermanSoftware", "NetCachingLibrary", "Tests", "log.txt");
cache.EnableLogging(fileLogPath);
             
//Log to memory
MemoryStream memoryStream = new MemoryStream();
cache.EnableLogging(ref memoryStream);
             
//Save it as a string
cache.Set<string>("Key", "This is a test");
             
//Loading it as an integer will throw an exception
try
{
	var result = cache.Get<int>("Key");
}
catch (Exception ex)
{
	Console.WriteLine(ex);
}
            
//Clear the file log
cache.ClearLog(fileLogPath);
'Create a Primary Memory Cache with a backing File Cache
Dim directory As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "KellermanSoftware", "NetCachingLibrary", "Tests")
Dim config As New SmartConfig(New MemoryCacheProvider(), New FileCacheProvider(directory))
             
'Specify UserName and LicenseKey for Licensed Mode
'config.UserName = "my user name";
'config.LicenseKey = "my license key";
             
'Instantiate the cache
Dim cache As New SmartCache(config)
             
'Turn on throwing exceptions (the default is true)
cache.ThrowExceptions = True
             
'Log to Console
cache.EnableLogging()
             
'Log to a File
Dim fileLogPath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "KellermanSoftware", "NetCachingLibrary", "Tests", "log.txt")
cache.EnableLogging(fileLogPath)
             
'Log to memory
Dim memoryStream As New MemoryStream()
cache.EnableLogging(memoryStream)
             
'Save it as a string
cache.Set(Of String)("Key", "This is a test")
             
'Loading it as an integer will throw an exception
Try
	Dim result = cache.Get(Of Integer)("Key")
Catch ex As Exception
	Console.WriteLine(ex)
End Try
            
'Clear the file log
cache.ClearLog(fileLogPath)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

SmartCache Class
SmartCache Members
Overload List