First of all, you should put UI code in proper order: instead of handling all those buttons and text boxes on ad-hoc basis normally offered by the Designer. Instead, you need to abstract out the set of centralized actions which are called on raw control events, such as button click, text change (by the way, not so easy in
System.Windows.Forms
, unlike some other libraries; you will have to handle raw mouse/keyboard events and then see if the text is changed), selection changes, and so on. This way, for example, if the same logical action is invoked when you click on a button or hit a default key, will be handled by the same action.
When this is done, you can (optionally) add logging to each of those actions. One ready-to-use logging tool is
System.Diagnostics.EventLog
:
http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog%28v=vs.110%29.aspx[
^].
It writes the logs to the system event log, but the sink of the log data can be customized, as well as nearly all other relevant detail. Please see my past answers:
MsBuild OutPut to the TextBox on the fly in Windows Application[
^],
How to create event log under a folder[
^].
And yes, as Wes Aday recommended, there is another option, log4net:
http://en.wikipedia.org/wiki/Log4net#Ports[
^],
http://logging.apache.org/log4net[
^].
—SA