/// <summary> /// Processes the queue item. /// </summary> /// <param name="item">The item.</param> protected override void ProcessQueueItem(LogItem item) { object[] args = item.Extra as object[]; //string message = "Type : " + item.LogType.ToString() + ", Message : " + item.Message; string message = item.Message; if (args == null) Console.WriteLine(message); else Console.WriteLine(message, (object[])args); }
/// <summary> /// Processes the queue item. /// </summary> /// <param name="item">The item.</param> protected override void ProcessQueueItem(LogItem item) { object[] args = item.Extra as object[]; if (this.ProcessLogItem != null) this.ProcessLogItem(item); }
/// <summary> /// Processes the queue item. /// </summary> /// <param name="item">The item.</param> protected override void ProcessQueueItem(LogItem item) { // Ensure the file in safe range and write the contents lock (_lockFile) { // file in safe range try { FileInfo fileInfo = new FileInfo(this.Source); if (fileInfo.Exists) { if (fileInfo.Length >= this.MaxFileSize) { string newFileName = String.Format(@"{0}\{1} {2:dd-MMM-yyyy HH.mm.ss.fff}.txt", fileInfo.DirectoryName, Path.GetFileNameWithoutExtension(fileInfo.FullName), DateTime.Now); try { File.Move(fileInfo.FullName, newFileName); } finally { this.OnFileMoved(this.Source, newFileName); } } } } catch (Exception ex) { EventLogExceptionAdapter.WriteException(ex); } // actual writing try { using (StreamWriter streamWriter = new StreamWriter(File.Open(this.Source, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))) { try { streamWriter.WriteLine(item.Message); } catch (Exception ex) { EventLogExceptionAdapter.WriteException(ex); } } } catch (Exception ex) { EventLogExceptionAdapter.WriteException(ex); } } }