NET Logging Library
Logging to a Memory Stream
Basic Tasks > Logging to a Memory Stream

The Memory Stream target is used to log to an in memory stream of bytes. 

It has these properties that can be configured:

 

 

//Example runtime configuration, can also use log.config, app.config, or web.config
Log.ResetConfiguration();  
MemoryStreamTarget target = new MemoryStreamTarget();      
Log.Config.Targets.Add(target);

Log.Debug("This is a test");

//Print the results of the log
target.MemStream.Seek(0, SeekOrigin.Begin);
Console.WriteLine(Encoding.UTF8.GetString(target.MemStream.ToArray()));