How can I query the path to an NLog log file?

后端 未结 3 2518
余生分开走
余生分开走 2021-02-20 12:36

I\'ve configured a file target for NLog as follows:


  
    

        
3条回答
  •  孤街浪徒
    2021-02-20 12:49

        private string GetLogFile()
        {
            var fileTarget = LogManager.Configuration.AllTargets.FirstOrDefault(t => t is FileTarget) as FileTarget;
            return fileTarget == null ? string.Empty : fileTarget.FileName.Render(new LogEventInfo { Level = LogLevel.Info });
        }
    

提交回复
热议问题