Logging user activity

  • Thread starter Thread starter scott
  • Start date Start date
S

scott

I would like to create a log file for my Windows forms app that logs
all user activity to help with debugging unhandled exceptions. I would
like to do this with a simple StreamWriter or TextWriter object.
Rather than define the object at the form level which would require me
to pass the object from form to form. What is the best way to keep the
object at a level above all forms so that all forms can write to the
log when needed? Thanks for the suggestions!

Scott Adams
~ not the Dilbert guy! ~
 
You can :
1. Define a log singleton to track the forms' events;
2. Define your own LogForm class derived from the
System.Windows.Forms.Form to override the default handlers (WndProc
itself or On<DoEvent>s) to track necessary events to the singleton log,
like:

protected override void OnSomeEvent(...)
{
/* do some */
Base.OnSomeEvent(...);
}

The prons of this approach is to have one (centralized) type for all
controlled forms.
Also you can use same approach for the controls.

WBR, Alex Meleta
Blog: http://devkids.blogspot.com


-----Original Message-----
From: scott [mailto:[email protected]]
Posted At: Freitag, 27. April 2007 21:47
Posted To: microsoft.public.dotnet.framework.windowsforms
Conversation: Logging user activity
Subject: Logging user activity

I would like to create a log file for my Windows forms app that logs
all user activity to help with debugging unhandled exceptions. I would
like to do this with a simple StreamWriter or TextWriter object.
Rather than define the object at the form level which would require me
to pass the object from form to form. What is the best way to keep the
object at a level above all forms so that all forms can write to the
log when needed? Thanks for the suggestions!

Scott Adams
~ not the Dilbert guy! ~
 
Back
Top