2016-01-13 26 views
0

我用這個例子http://nlog-project.org/documentation/v2.0.1/html/T_NLog_Targets_MemoryTarget.htm如何讀取MemoryTarget NLOG登錄物品異步

,我想,我們如何從MemoryTargetNLOG閱讀Log項目異步填充RichTextBox例如?

using System; 

using NLog; 
using NLog.Targets; 

class Example 
{ 
    static void Main(string[] args) 
    { 
     MemoryTarget target = new MemoryTarget(); 
     target.Layout = "${message}"; 

     NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target, LogLevel.Debug); 

     Logger logger = LogManager.GetLogger("Example"); 
     logger.Debug("log message"); 

     foreach (string s in target.Logs) 
     { 
      Console.Write("logged: {0}", s); 
     } 

     // Access to target.Logs async. 
     // Have I target.Logs.Clear() the Logs when I get all items? 
    } 
} 

任何線索?

回答