0

Hi i am using Enterprise library 5.0 to log messages in text file, as a part of that i need to log collection of messages to the text file .

Below is the part of code which logs to text file using flatfilelistener

public void LogToFile(string message, string category, IDictionary<string, object> additionalDetail)
{
    var logger = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();

    logger.Write(message, category, 0, 0, TraceEventType.Error, string.Empty, additionalDetail);
}

The above will log single message in text file, like that i will call for each item in collection which i need to log.

So , how to log everything in single stretch? like placing in buffer and updating logfile on single stretch.

I guess there is one property named "AutoFlush" but i don't know how to use that.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Max_dev
  • 508
  • 7
  • 25

1 Answers1

1

using auto flush

That is likely your best bet. Just let the buffer handle it or create a custom flush mechanism that you can call at a specified duration such as the end of a http request or if you are paranoid perhaps when an application crashes and you can't trust autoflush to work.

Community
  • 1
  • 1
Rob Allen
  • 2,871
  • 2
  • 30
  • 48