I am in the middle of developing an application that requires a fair degree of interaction with the user. The primary customer has proven to be unreliable in describing what selections/actions he has performed when reporting a problem. I have used logging on all the event handlers to capture the user's clicks. The log files do get long, but I can see excatly how the user has interacted with the program. I have not seen any noticeable degradation to the application's performance. The user now sends me the log file rather than to describe from memory what was done, so easier on him and it's a big help in analyzing problem reports.
Thanks, Mike -----Original Message----- From: Nicko Cadell [mailto:[EMAIL PROTECTED] Sent: Thursday, May 06, 2004 5:07 AM To: '[email protected]' Cc: '[EMAIL PROTECTED]' Subject: RE: how to log/trace all the operations performed by the operator? Paul, Probably a question for the log4net-user list. http://logging.apache.org/log4net/support.html Are you sure that you want to log messages for every method entry and exit? Do you think this will be useful for you or will it just generate a lot of log messages that you never read and potentially make it harder to see the genuine error messages. There is a cost involved in adding logging to an application. The cost is both time taken to add and maintain the logging calls and the performance cost of making those calls. You should think carefully about the appropriate level of logging you require. The simple and straight forward answer to how to log method entry and exit is to just add logging calls at the start and end of the method, however it is quite complex to do it correctly, especially regarding exceptions. You may consider something like this: int Count(string data) { if (log.IsDebugEnabled) log.Debug("IN Count("+data+")"); int result = 0; try { // do the work for the function here // note that any operation can throw exceptions result = data.Length; } catch(Exception ex) { if (log.IsDebugEnabled) log.Debug("OUT Count [EXCEPTION]", ex); throw; } if (log.IsDebugEnabled) log.Debug("OUT Count "+result); return result; } However that is rather a lot of work and makes the methods look ugly. In my experience this does not ultimately prove useful, your experience and problem domain may be different. I tend to add log events wherever a failure can occur and when ever a significant event occurs, the definition of significant is application specific. When I debug applications I add additional log methods to help determine the error, I never remove these log messages, if they were useful once they will be again. The .NET framework has a profiler API which can be used to trace the execution of the code within a VM. This can be used to trap and log all method entry and exit points along with their arguments and return values. If you seriously think you need to trace all method entry exit points then this may be a better method of achieving this. With the profiler API you will not need to modify your code to add log methods at each point. Cheers, Nicko > -----Original Message----- > From: Paul Rayer [mailto:[EMAIL PROTECTED] > Sent: 04 May 2004 10:56 > To: [EMAIL PROTECTED] > Subject: how to log/trace all the operations performed by the > operator? > > Hi, > > I have implemented many of the appenders to test the logging. > But, all I have done is to use the logger to trap the > exceptions only, as given below: > > try > { > FileStream fs=new > FileStream("c:\test.dat",FileMode.Open,FileAccess.Read); > } > catch(Exception myException) > { > log.Warn(myException.ToString()); > } > > > My question is: how should log4net be implemented to log the > events like control entering into a method, control coming > out of a method, doing some calculation etc., In short, it > should trace all the operations the user does, while running > an application. > > How should I do this? > > Thanks & Regards > Paul >
