NET Logging Library
Flush Method (Log)
Example 



KellermanSoftware.NetLoggingLibrary Namespace > Log Class : Flush Method
Wait for the specified number of milliseconds for asynchronous targets to log
Syntax
Public Shared Function Flush( _
   ByVal maxMillisecondsToWait As Integer _
) As Boolean
Dim maxMillisecondsToWait As Integer
Dim value As Boolean
 
value = Log.Flush(maxMillisecondsToWait)
public static bool Flush( 
   int maxMillisecondsToWait
)
public:
static bool Flush( 
   int maxMillisecondsToWait
) 

Parameters

maxMillisecondsToWait
Example
//Licensed Mode
//Log.UserName = "User Name From Receipt";
//Log.LicenseKey = "LicenseKey From Receipt";            
 
//Clear all configuration
Log.ResetConfiguration();
 
//Add a new target, you can also define targets in an xml file, app.config, or web.config
FileTarget fileTarget = new FileTarget(Environment.CurrentDirectory + "\\fileLogger.txt");
fileTarget.Mode = LoggingMode.Asynchronous;         
 
//Add it to the targets
Log.Config.Targets.Add(fileTarget);
 
//For the file target, this is a non blocking operation, it will be written on a seperate thread
Log.Debug("This is a test");
 
//Parameters
int maxMillisecondsToWait = 1000;
 
//Wait a second for it to be written
bool wasFlushedDuringTheWaitTime = Log.Flush(maxMillisecondsToWait);
 
Console.WriteLine(wasFlushedDuringTheWaitTime);
'Licensed Mode
'Log.UserName = "User Name From Receipt";
'Log.LicenseKey = "LicenseKey From Receipt";            
 
'Clear all configuration
Log.ResetConfiguration()
 
'Add a new target, you can also define targets in an xml file, app.config, or web.config
Dim fileTarget As New FileTarget(Environment.CurrentDirectory & "\fileLogger.txt")
fileTarget.Mode = LoggingMode.Asynchronous
 
'Add it to the targets
Log.Config.Targets.Add(fileTarget)
 
'For the file target, this is a non blocking operation, it will be written on a seperate thread
Log.Debug("This is a test")
 
'Parameters
Dim maxMillisecondsToWait As Integer = 1000
 
'Wait a second for it to be written
Dim wasFlushedDuringTheWaitTime As Boolean = Log.Flush(maxMillisecondsToWait)
 
Console.WriteLine(wasFlushedDuringTheWaitTime)
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

Log Class
Log Members