I recently had the opportunity to check out a software package that does logging for several platforms, .NET, Delphi and Java. The software is called SmartInspect and it’s by Gurock Software (www.gurock.com). SmartInspect adds a very flexible methodology to do logging in your software. Being a full time .NET programmer, I examined their API for logging in this platform only.
.NET has built in tracing and logging so why do you need another package? Because they do all the hard work of making the .NET logging useful! They provide an easy way to log all .NET types and more importantly, get the logged data back in a useful way to make intelligent decisions based on it. More on that later.
Another cool feature that they offer is the output of logs to either a file or a tcp client. This allowed me to direct the output of the log when running in debug mode directly to their log viewer. No fooling with log files in development! Every run of the program is right in front of me.You could also direct live clients to a tcp server to do large collections of data if you needed to.
So how do we log something? Is it easy? No, it’s very easy. The learning curve is small and the API is intuitive.I was almost fully up to speed in about two hours. Even if you haven’t used a particular method before, the names make sense. For example, to log the start of a method you use:
The end of a method?
There are many different logging methods for the native .NET types. SmartInspect’s done all the hard work of parsing the type you pass to them and extracting meaningful information to show you later. They range from simple types to much more complex types like a DataSet.
bool MyBool = true;
DataSet MyDataSet = new DataSet();
OK so that’s all nice, but now what do I do with all this information? One of the major downsides to logs are that they usually have thousands of entries that are plain text. It’s up to you to figure out how and what do to with all the megabytes of text. SmartInspect solves this problem very well. The real power of the tool is in their log viewer.
It’s very customizable and presents the log information in a well laid out manner. Below is a screen shot of a few things I logged in a button click.
You can see the button1_click entry point and exit, along with a Boolean, DataSet and exception that I logged. Each type of log entry has an associated viewer that allows you to see the information for the entry. Below is the DataSet (a single table, with 2 columns ID and Name) that I logged. Notice that it shows the two records that were in it.