public FileArchiveModeDynamicSequence(ArchiveNumberingMode archiveNumbering, string archiveDateFormat, bool customArchiveFileName, bool archiveCleanupEnabled) : base(archiveCleanupEnabled) { _archiveNumbering = archiveNumbering; _archiveDateFormat = archiveDateFormat; _customArchiveFileName = customArchiveFileName; }
public static IFileArchiveMode CreateArchiveStyle(string archiveFilePath, ArchiveNumberingMode archiveNumbering, string dateFormat, bool customArchiveFileName, int maxArchiveFiles) { if (ContainsFileNamePattern(archiveFilePath)) { IFileArchiveMode archiveHelper = CreateStrictFileArchiveMode(archiveNumbering, dateFormat, maxArchiveFiles); if (archiveHelper != null) { return(archiveHelper); } } if (archiveNumbering != ArchiveNumberingMode.Sequence) { if (!customArchiveFileName) { IFileArchiveMode archiveHelper = CreateStrictFileArchiveMode(archiveNumbering, dateFormat, maxArchiveFiles); if (archiveHelper != null) { return(new FileArchiveModeDynamicTemplate(archiveHelper)); } } else { InternalLogger.Info("FileTarget: Pattern {{#}} is missing in ArchiveFileName `{0}` (Fallback to dynamic wildcard)", archiveFilePath); } } return(new FileArchiveModeDynamicSequence(archiveNumbering, dateFormat, customArchiveFileName)); }
private static IFileArchiveMode CreateStrictFileArchiveMode(ArchiveNumberingMode archiveNumbering, string dateFormat, int maxArchiveFiles) { switch (archiveNumbering) { case ArchiveNumberingMode.Rolling: return(new FileArchiveModeRolling()); case ArchiveNumberingMode.Sequence: return(new FileArchiveModeSequence(dateFormat)); case ArchiveNumberingMode.Date: return(new FileArchiveModeDate(dateFormat, ShouldDeleteOldArchives(maxArchiveFiles))); case ArchiveNumberingMode.DateAndSequence: return(new FileArchiveModeDateAndSequence(dateFormat)); } return(null); }
private static IFileArchiveMode CreateStrictFileArchiveMode(ArchiveNumberingMode archiveNumbering, string dateFormat, bool archiveCleanupEnabled) { switch (archiveNumbering) { case ArchiveNumberingMode.Rolling: return(new FileArchiveModeRolling()); case ArchiveNumberingMode.Sequence: return(new FileArchiveModeSequence(dateFormat, archiveCleanupEnabled)); case ArchiveNumberingMode.Date: return(new FileArchiveModeDate(dateFormat, archiveCleanupEnabled)); case ArchiveNumberingMode.DateAndSequence: return(new FileArchiveModeDateAndSequence(dateFormat, archiveCleanupEnabled)); } return(null); }
private void GenerateArchives(int count, string archiveDateFormat, string archiveFileName, ArchiveNumberingMode archiveNumbering) { string logFileName = Path.GetTempFileName(); const int logFileMaxSize = 1; var ft = new FileTarget { FileName = logFileName, ArchiveFileName = archiveFileName, ArchiveDateFormat = archiveDateFormat, ArchiveNumbering = archiveNumbering, ArchiveAboveSize = logFileMaxSize }; SimpleConfigurator.ConfigureForTargetLogging(ft, LogLevel.Debug); for (int currentSequenceNumber = 0; currentSequenceNumber < count; currentSequenceNumber++) logger.Debug("Test {0}", currentSequenceNumber); }
public static IFileArchiveMode CreateArchiveStyle(string archiveFilePath, ArchiveNumberingMode archiveNumbering, string dateFormat, bool customArchiveFileName, int maxArchiveFiles) { if (ContainsFileNamePattern(archiveFilePath)) { IFileArchiveMode archiveHelper = CreateStrictFileArchiveMode(archiveNumbering, dateFormat, maxArchiveFiles); if (archiveHelper != null) { return(archiveHelper); } } if (archiveNumbering != ArchiveNumberingMode.Sequence && !customArchiveFileName) { IFileArchiveMode archiveHelper = CreateStrictFileArchiveMode(archiveNumbering, dateFormat, maxArchiveFiles); if (archiveHelper != null) { return(new FileArchiveModeDynamicTemplate(archiveHelper)); } } return(new FileArchiveModeDynamicSequence(archiveNumbering, dateFormat, customArchiveFileName)); }
public FileArchiveModeDynamicSequence(ArchiveNumberingMode archiveNumbering, string archiveDateFormat, bool customArchiveFileName) { _archiveNumbering = archiveNumbering; _archiveDateFormat = archiveDateFormat; _customArchiveFileName = customArchiveFileName; }
public static bool UseFileLogging(NLog.LogLevel logLevel, string filename, string layout, string archiveFileName, long archiveAboveSize, ArchiveNumberingMode archiveNumbering) { LoggingOption = LoggingOptions.FileLogging; LogLevel = logLevel; FileLoggingFileName = filename; FileLoggingArchiveFileName = archiveFileName; FileLoggingArchiveAboveSize = archiveAboveSize; FileLoggingArchiveNumbering = archiveNumbering; return NLogHelper.Configuration.UseFileLogging(logLevel, filename, layout, archiveFileName, archiveAboveSize, archiveNumbering); }