NET Logging Library
Asynchronous Logging
Basic Tasks > Asynchronous Logging

By default, all logging targets are synchronous blocking operations.  If the target is slower than required, it can be easily switched to a non-blocking logging. The configuration can be defined using runtime properties, a log.config file, or the app.config/web.config.

Example Runtime Configuration


//Clear all the configuration
Log.Config.ResetConfiguration();

//Add a Target and make it Asynchronous
FileTarget fileTarget = new FileTarget("log.txt");
fileTarget.LoggingMode = LoggingMode.Asynchronous;
Log.Config.Targets.Add(fileTarget);

 

//When your application exits, use the Flush to wait for Asynchronous Logging targets

//Wait for a maximum of 2 seconds

Log.Flush(2000);