/// <summary> /// Initializes a new instance of the <see cref="MutexMultiProcessFileAppender" /> class. /// </summary> /// <param name="fileName">Name of the file.</param> /// <param name="target">The file target.</param> public MutexMultiProcessFileAppender(string fileName, FileTarget target) : base(fileName) { try { this.mutex = new Mutex(false, GetMutexName(fileName)); this.file = target.CreateFileStream(fileName, true, true); } catch { if (this.mutex != null) { this.mutex.Close(); this.mutex = null; } if (this.file != null) { this.file.Close(); this.file = null; } throw; } }
/// <summary> /// Initializes a new instance of the <see cref="CountingSingleProcessFileAppender" /> class. /// </summary> /// <param name="fileName">Name of the file.</param> /// <param name="target">The file target.</param> public CountingSingleProcessFileAppender(string fileName, FileTarget target) : base(fileName) { var fi = new FileInfo(fileName); if (fi.Exists) { this.FileTouched(fi.LastWriteTime); this.currentFileLength = fi.Length; } else { this.FileTouched(); this.currentFileLength = 0; } this.file = target.CreateFileStream(fileName, false, false); }