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

后端 未结 3 1151
心在旅途
心在旅途 2021-02-20 12:29

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


  
    

        
3条回答
  •  走了就别回头了
    2021-02-20 13:07

        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 });
        }
    

提交回复
热议问题