Application LoggingThere are many logging components available today, both Open Source and proprietary. Microsoft and others working on the CLI specification had the foresight to build logging into System.Diagnostics.Trace. By using the Trace class in conjunction with System.Diagnostics.TraceListner, System.Diagnostics.Switch, and their child classes, you can do rudimentary logging using only the CLI. Most developers find that the built-in CLI framework's functionality is better than that of previous languages but still lacking in that they cannot log to the targets they want or log in a specific, configurable way.TIPAs shown later in Table 8.3, Log4NET has a TraceAppender output that can output just like a regular TraceListener but of course with a lot more configurable outputs.http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/emab-rm.asp) that is a little better than the CLI logging at being exception-aware, and they recently announced the Logging Application Block (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/Logging.asp?frame=true) that goes even further into application logging under some sort of end user license agreement. Justin Rudd originally ported LogKit (http://avalon.apache.org/logkit/), another Apache project, and I added a lot of functionality to it. You can find it at http://www.sourceforge.net/projects/logkit-net.NOTE Watch for the C# version of the Apache group's Avalon framework (http://www.apache.org/~hammett/avalondotnet/indexl). This project will provide a standard way to handle exceptions, logging, advanced serialization, and more! Similar projects are available under shared source from Microsoft's Pattern & Practices group (see the Application Blocks available from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/emab-rm.asp).By far, the best logging kit available on the market happens to be Log4Net (http://log4net.sourceforge.net), and it also happens to be Open Source. Log4Net is a .NET port of a popular Java tool, Log4J. Log4J is a stable tool that has seen a lot of runtime and has been ported to many languages with great success. It's based on the research of the SEMPER (http://www.semper.org) group who, commissioned by the European Union to create a secure framework for e-commerce, decided to create their own logging API.Some developers, especially with a C++ background, do not initially see the advantages of runtime logging over compile-time tracing. While allowing the compiler to map out all trace statements is the most popular type of logging available, it is not at all flexible. Runtime logging offers the advantage of setting and changing level thresholds at runtime for the code or even turning the logging off altogether. The advantages of this type of flexibility outweigh the proportionately small performance loss in most developers' minds. |