C# 3.0 带有日期的nlog文件

C# 3.0 带有日期的nlog文件,c#-3.0,nlog,C# 3.0,Nlog,在C#2008应用程序中,我希望写出NLog错误日志文件,以便文件上有日期。在下面列出的示例中,您可以看到我有3个日志文件。你能告诉我如何在这些文件上放置月-日-年格式吗 <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <sectionGroup name="spring"> <section name="context" type=

在C#2008应用程序中,我希望写出NLog错误日志文件,以便文件上有日期。在下面列出的示例中,您可以看到我有3个日志文件。你能告诉我如何在这些文件上放置月-日-年格式吗

 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
 <configSections>
  <sectionGroup name="spring">
  <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
  <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
   </sectionGroup>
   <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
   </configSections>
   <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"  
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <targets>
  <target name="logfile" xsi:type="File" fileName="C:\Logs\NlogOutput.log" />
  </targets>
  <rules>
  <logger name="*" minlevel="Info" writeTo="logfile" />
  </rules>
  </nlog>

文件名
参数使用如下内容:

fileName="${basedir}/${shortdate}.log"
一般来说,您可以使用大多数NLog LayoutRenderer来帮助编写文件名