NLog.Targets.FileTarget.ArchiveByDate C# (CSharp) 메소드

ArchiveByDate() 개인적인 메소드

Archives the fileName using a date style numbering. Archives will be stamped with the prior period (Year, Month, Day, Hour, Minute) datetime. When the number of archive files exceed the obsolete archives are deleted.
private ArchiveByDate ( string fileName, string pattern, LogEventInfo logEvent ) : void
fileName string File name to be archived.
pattern string File name template which contains the numeric pattern to be replaced.
logEvent LogEventInfo Log event that the instance is currently processing.
리턴 void
        private void ArchiveByDate(string fileName, string pattern, LogEventInfo logEvent)
        {
            string dirName = Path.GetDirectoryName(Path.GetFullPath(pattern));
            if (dirName != null)
            {
                DateTime archiveDate = GetArchiveDate(fileName, logEvent);
                string fileNameMask = ReplaceFileNamePattern(pattern, "*");
                string dateFormat = GetArchiveDateFormatString(this.ArchiveDateFormat);
                string archiveFileName = Path.Combine(dirName, fileNameMask.Replace("*", archiveDate.ToString(dateFormat)));
                ArchiveFile(fileName, archiveFileName);
            }

            DeleteOldDateArchives(pattern);
        }