tags:

views:

34

answers:

2

I have a winform containing controls that are updated when a new instance of my business logic class is instantiated. And with the use of a timer, fields in my class (and their associative labels) are updated every few seconds.

This is all working fine, except for one control - a rich text box acting as a log of all the activity.

The problem is this: though I want all the other controls to be refreshed when a new class is instantiated, I don't want the log to be refreshed. I want it to store all the previous activity (from the current session; it doesn't need to persist between application lifetimes.)

I can't store the log data in a class instance obviously, so what method should I be using? Is it worth creating a Singleton for this?

And how should I go about adding an entry to the log?

+1  A: 

When it comes to logging, don't reinvent the wheel. There are a few free, solid logging tools out there:

NLog

log4net

If I recall right, NLog has built-in support for writing its log to a text box.

Judah Himango
A: 

Posted as an answer from my original comment, as requested by fieldingmellish:

If this is string data, you could just store it in your form, or in objects contained by your form.

Andy West