Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nlog 是否可以在internalLogFile中使用${shortdate}?_Nlog - Fatal编程技术网

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";