Make .Net debugging easier – using log4net logs

My current logging strategy for debugging

In a method, at a debug level, log at least the values of each parameter you are passing in. For Example:

With a method defined like this:

public int DoThisThing(int firstNumber, int secondNumber)

My log4net statement might look like this:

Log.InfoFormat(“MyClass just ran DoThisThingwith firstNumber’{0}’ and secondNumber’{1}’”, firstNumber, secondNumber);

I find myself using this as a persistent debugging tool. It can be really handy to read back through the logs.

I generally use the Colored Console Appender if I am watching live.

If you haven’t used them, the technologies I am talking about are:

log4net

BareTail (for watching multiple logs or reading old logs)

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.