Nlog 是否可以在internalLogFile中使用${shortdate}?
是否可以在Nlog 是否可以在internalLogFile中使用${shortdate}?,nlog,Nlog,是否可以在内部日志文件中使用${shortdate} <nlog internalLogFile="C:\Logs\${shortdate}_nlog.log" <targets> <target name="logfile" fileName="C:/logs/${shortdate}_dev.log" </target> 简短回答:否 更详细的回答:内部记录器文件名只是一个字符串。它
内部日志文件中使用${shortdate}
<nlog internalLogFile="C:\Logs\${shortdate}_nlog.log"
<targets>
<target name="logfile"
fileName="C:/logs/${shortdate}_dev.log"
</target>
简短回答:否
更详细的回答:内部记录器文件名只是一个字符串。它在初始化过程中被读入,XmlLoggingConfiguration
类确保目录存在,而FileTarget
使用布局
作为文件名,该布局转换使用LayoutRenders
提供的值
通过阅读他们的评论,我的理解是,内部日志记录应该简单、稳定,并且使用量要少。通常情况下,您只需要在试图找出设置中的问题时打开它
如果需要,您仍然可以根据日期和时间动态命名内部日志文件。但是,它不会具有与目标文件相同的滚动效果。我认为,无论何时初始化记录器,它都会有一个不同的日期时间
DateTime dt = DateTime.Now;
NLog.Common.InternalLogger.LogFile = @"C:\CustomLogs\NLog_Internal\internal_NLogs" + dt.ToString("yyyy-MM-dd") + ".txt";