Wrong content RollingFile Log

夙愿已清 提交于 2019-12-12 03:48:07

问题


I'm using RollingFile log from Enterprise Library and I'm configuring it by this way:

    var builder = new ConfigurationSourceBuilder();

    builder.ConfigureLogging()
      .LogToCategoryNamed("General")
      .WithOptions.SetAsDefaultCategory()                   
      .SendTo.RollingFile("Log File")
      .RollEvery(Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollInterval.Day)
      .UseTimeStampPattern("yyyyMMdd")
      .WhenRollFileExists(Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollFileExistsBehavior.Overwrite)
      .FormatWith(new FormatterBuilder()
            .TextFormatterNamed("Text Formatter")
            .UsingTemplate("{message}"))
     .ToFile(SettingsHelper.LogFilePath)                         
     .WithHeader(string.Empty)
     .WithFooter(string.Empty);                         

      var configSource = new DictionaryConfigurationSource();
      builder.UpdateConfigurationWithReplace(configSource);
      EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource);

My problem is:

The log must be one file per day, ok, it is done. But when I open the log file of date 04/21/2016 for example, the content is of date 04/20/2016. Why is this happen? Is something wrong in the configuration?

来源:https://stackoverflow.com/questions/36767555/wrong-content-rollingfile-log

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!