名称空间Nlog中不存在类型或命名空间名称GlobalDiagnosticsContext

时间:2014-05-31 03:25:10

标签: c# logging nlog

我开始探索NLog日志记录框架中的功能。当我尝试使用不同的日志记录功能时,我遇到了一个名为logging Header message的功能。我的搜索在堆栈中找到了Link

但是当粘贴以下行时

 public void AddHeaderToLogFile()
 {
     Logger headerlogger = LogManager.GetLogger("HeaderLogger");

      //Use GlobalDiagnosticContext in 2.0, GDC in pre-2.0
      GlobalDiagnosticContext["releasedate"] = GetReleaseDate();    
      GlobalDiagnosticContext["version"] = GetFileVersion();     
      GlobalDiagnosticContext["someotherproperty"] = GetSomeOtherProperty();

      headerlogger.Info("message doesn't matter since it is not specified in the layout");

      //Log file should now have the header as defined by the HeaderLayout

      //You could remove the global properties now if you are not going to log them in any
      //more messages.
}

我的VS 2013无法解析命名空间。我目前的NLog程序集版本是2.1.0.0。 请让我知道如何解决我的命名空间问题。我使用的是正确的装配,还是应该转移到某些预发布版本或旧版本。

0 个答案:

没有答案