Exemplo n.º 1
0
 /// <summary>
 /// Constructor with initializeData.
 /// </summary>
 /// <param name="filePathTemplate">Template filename to log to; may use replacement parameters.</param>
 /// <remarks>
 /// <para>
 /// A rolling log file is achieved by including the date in the filename, so that when the date changes
 /// a different file is used.
 /// </para>
 /// <para>
 /// Available tokens are DateTime (a UTC DateTimeOffset) and LocalDateTime (a local DateTimeOffset),
 /// as well as ApplicationName, ProcessId, ProcessName and MachineName. These use standard .NET
 /// format strings, e.g. "Trace{DateTime:yyyyMMddTHH}.log" would generate a different log name
 /// each hour.
 /// </para>
 /// <para>
 /// The default filePathTemplate is "{ApplicationName}-{DateTime:yyyy-MM-dd}.log", which matches
 /// the format used by Microsoft.VisualBasic.Logging.FileLogTraceListener (except that it uses
 /// UTC time instead of local time).
 /// </para>
 /// <para>
 /// To get behaviour that exactly matches FileLogTraceListener,
 /// use "{ApplicationName}-{LocalDateTime:yyyy-MM-dd}.log".
 /// </para>
 /// </remarks>
 public RollingFileTraceListener(string filePathTemplate)
 {
     if (string.IsNullOrEmpty(filePathTemplate))
     {
         rollingTextWriter = new RollingTextWriter(_defaultFilePathTemplate);
     }
     else
     {
         rollingTextWriter = RollingTextWriter.Create(filePathTemplate);
     }
 }
 /// <summary>
 /// Constructor with initializeData.
 /// </summary>
 /// <param name="filePathTemplate">Template filename to log to; may use replacement parameters.</param>
 /// <remarks>
 /// <para>
 /// A rolling log file is achieved by including the date in the filename, so that when the date changes
 /// a different file is used.
 /// </para>
 /// <para>
 /// Available tokens are DateTime (a UTC DateTimeOffset) and LocalDateTime (a local DateTimeOffset), 
 /// as well as ApplicationName, ProcessId, ProcessName and MachineName. These use standard .NET 
 /// format strings, e.g. "Trace{DateTime:yyyyMMddTHH}.svclog" would generate a different log name
 /// each hour.
 /// </para>
 /// <para>
 /// The default filePathTemplate is "{ApplicationName}-{DateTime:yyyy-MM-dd}.svclog", which matches
 /// the format used by Microsoft.VisualBasic.Logging.FileLogTraceListener (except that it uses
 /// UTC time instead of local time).
 /// </para>
 /// <para>
 /// To get behaviour that exactly matches FileLogTraceListener, 
 /// use "{ApplicationName}-{LocalDateTime:yyyy-MM-dd}.svclog".
 /// </para>
 /// </remarks>
 public RollingXmlTraceListener(string filePathTemplate)
 {
     if (string.IsNullOrEmpty(filePathTemplate))
     {
         rollingTextWriter = new RollingTextWriter(_defaultFilePathTemplate);
     }
     else
     {
         rollingTextWriter = RollingTextWriter.Create(filePathTemplate);
     }
 }