Building a Logging Framework in ASP.NET 1.x – Part 1
One of the most enjoyable aspects of system architecture is designing new frameworks for new applications. This is the point in time of the design process where you can be the most creative and bring new design patterns and new knowledge to the table to continually build most robust, scalable and stable applications.
There are of course a few key staple infrastructures that need to be in place in nearly every application. Sometimes it’s fun to change it up and design these pieces in different ways to keep things fresh. There’s only so many ways you can create a login form for example.
One of the key foundation pieces to nearly any application is logging. Logging can be implemented in a myriad of different ways, depending on the scope of the application. Certain pieces are not always needed and sometimes using the built in .NET tracing is sufficient. Personally I always want full control over my logging needs so I always create my own logging framework from scratch.
The main purpose of most logging frameworks is to capture exceptions. Handling exceptions is paramount is application maintenance: If you cannot track down your bugs efficiently your application and end-user performance will suffer greatly. You therefore need a descent exception logging mechanism which will allow you to pinpoint errors in your application hastily.
Secondary logging purposes include tracing or debug statements. This can help expedite the development process by creating custom messages around complex algorithms which can help remove a lot of trial-and-error debugging and testing.
The purpose of this tutorial is to design a basic yet useful logging framework which is Object Oriented and expandable to larger scale needs should your application require it. Part 1 of this tutorial will focus on implement most of the foundation of the logging framework and the basics of how to use it. The second and final part of this tutorial will put the logging framework into a basic ASP.NET application structure and show you how to use the logging framework in a more real-world structure.
Note: Visual Studio .NET 2002/2003 running ASP.NET 1.x is required to implement this tutorial. Both C# and VB.NET code samples will be provided