2

I am using the microsoft enterprise library 6 for a short time now. The formatted logging for example to a text file or to console works fine, but I am failing to find a way to display these log messages inside my windows-forms applications.

So what I want to do is to display exact the same formatted messages that I log with FlatFileTraceListener to a file, in a log window/text box inside a windows forms app.

as a workaround I initialized a

FormattedTextWriterTraceListener(TextWriter writer, string name, ILogFormatter formatter);

With a StringWriter as TextWriter and fire an event manually every time I log a message and then update the whole text box when the event is raised with the new text but this does not look like a clean solution.

Does anyone have a solution?

  • Does it have to be real time or on demand? For on demand, you could just read in the log file (determine the log file name from config and read it in). Your solution seems OK to me. To make it a bit cleaner, instead of using StringWriter and an event, create your own TextWriter that appends directly to the TextBox as in: https://stackoverflow.com/questions/14802876/what-is-a-good-way-to-direct-console-output-to-text-box-in-windows-form . – Randy Levy Nov 14 '14 at 17:11

0 Answers0