Thursday, July 21, 2005

Logging on the SMT5600

I'm currently exploring ways to integrate logging into my application. I noticed that .NET Framework 2.0 has a class called Microsoft.Build.Utilities.Logger however this isn't available for .NET CF 2.0 much less .NET 1.0. Through a somewhat brief google driven investigation, I've determined that log4net appears to be the standard and, as the name implies, isn't much different from log4j and like that java library, is also an Apache OSS project. There are also other, less dramatic options.

For example, Neil Cowburn talks about ultra-simple application logging, though it does require P/Invoke.

This is a really cool technique that you can use to add simple logging/tracing functionality to your .NET Compact Framework apps. In Windows CE, there is a Win32 API which goes by the moniker of SetStdioPathW. By calling this API, you can redirect standard input, output and error output. The cool thing about this is that you can actually redirect the I/O to a text file! By redirecting standard output like this, you can scatter Console.WriteLine()'s all throughout your code and hey presto! Instant instrumentation. (link)

There is also nspring written by Jeff Varszegi, which seems to be a fairly complete logger he wrote by himself in ~1 month. You can read about it here.

No comments: