Click here to Skip to main content
15,867,686 members
Articles / Web Development / IIS / IIS 7.0
Article

Logging System for .NET SOA Applications

Rate me:
Please Sign up or sign in to vote.
3.67/5 (6 votes)
30 Dec 2007CPOL4 min read 44K   408   50   3
No matter how well you design your system, a distributed SOA application is always complex. When a SOA application fails, it can be difficult to track down the cause of the problem and the Web service where the error occurred. To handle this difficulty, you need a logging system such as UptoLog.

Introduction

No matter how well you design your system, a distributed SOA application is always complex. When an SOA application fails, it can be difficult to track down not only the cause of the problem but also the component and Web service where the error occurred. Logs from the same error are likely to be positioned on different machines, collocated with the Web service and the consumer participating in the activity. When finding the cause of the problem, it is necessary to piece together logs from different machines. It is difficult to figure out how the Web service was consumed, when the error occurred. Also, there is no easy mechanism to capture the flow of activities end-to-end within the system, as they occur.

To handle this difficulty, you need a reliable logging system which could be UptoLog. In this article, I will look into UptoLog and describe how this log system is used in a .NET SOA application.

Using UptoLog

UptoLog is designed to gather detailed information about application failures in .NET 2.0, 3.0 and 3.5 applications. The system logs errors and generates trace and time measurements across multiple logical and physical layers. Log data is gathered in one central database. All log data gathered during a specific activity are related through a unique activity ID. This makes it possible to group errors, traces and time measurements for a specific activity across many layers from end-to-end within the system.

The figure shows how the UptoLog logging system is integrated into an SOA application.

Using UptoLog in a SOA application

You can find detailed information about the different components in the UptoLog logging system here.

UptoLog Search Server is a Web application with a straightforward search tool. This enables you to search the gathered log data and survey an application failure, or observe the actual response time of the system through time measurements across multiple machines.

For example if an application error occurs, the Web service consumer and context is automatically visualized, because the error logs are gathered in one central database from all layers in the application and the logs are grouped per activity.

Here are two examples of how logs are visualized through UptoLog Search Server.

Shown below is a screen shot from an application failure showing two error logs, from two different layers, grouped per activity:

UptoLog screen shot, showing application failure

The following is a screen shot showing time measurements from an activity, which in correlation shows the response time of the SOA application:

UptoLog screen shot, showing time measurements

If you would like to try these examples, the test application used in the examples can be downloaded here. The test application is located in a .NET 2.0 solution that also contains other examples.

Logging with UptoLog

An application logs through the UptoLog Satellite component, which is integrated into all the consumer and Web service applications in the SOA application.

The logging functionality is shortly described below. A more detailed description can be found here.

An error is logged by a method call. UptoLog logs errors in three different error levels. Depending on the wanted error level, one of the following methods is used: LogFatalError, LogError, or LogWarning. This shows how a fatal error is logged:

C#
try
{
 // The application code that can cause the error.
}
catch (Exception exc)
{ 
 Log.LogFatalError(exc); // Logging fatal error.
}

Traces are collected by UptoLog Satellite which sends the trace loggings in packages.
This shows how a trace is generated:

C#
private void SomeMethod()
{
 Log.LogTraceItem("Trace text before the code is executed");

 // Some application code.
 Log.LogTraceItem("Trace text after the code is executed");
}

UptoLog Satellite collects the time measurements and sends the measurements in packages. The time measurements can generally be generated in two different ways.

This shows how time measurements are generated:

C#
// First method
private void SomeMethod()
{
 TimeMeasure tm = Log.BeginTimeMeasure("Name of the time measurement");

 // Some application code.
 tm.EndTimeMeasure();
} 

// Second method
private void SomeMethod()
{
 using (Log.BeginTimeMeasure("Name of the time measurement"))
 {
  // Some application code.
 } // The time measurement is automatically stopped even though
   // the application code faults.
} 

Activities in UptoLog

UptoLog Satellite holds an activity guid in the consumer which must be renewed every time a new activity is begun. When a Web service is called by a consumer, the Web service request is part of an activity which is started outside the Web service. It is therefore necessary to read the activity guid (activity ID) in UptoLog Satellite at the consumer, send the activity guid with the Web service call and hand it to UptoLog Satellite in the Web service.

The activity guid is renewed like this:

C#
Log.StartNewActivityId(); 

The activity guid can subsequently be read in UptoLog Satellite at the consumer like this:

C#
Guid someActivityId = Log.CurrentActivityId; 

The activity guid received by the Web service call is handed to UptoLog Satellite in the Web service like this:

C#
Log.CurrentActivityId = someActivityId;

General Information

UptoLog 2008 is released and the trial edition can be tried out for free for 30 days. You can download UptoLog Trial Edition here.

You can find more information about UptoLog here.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Denmark Denmark
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 1 Pin
Syed J Hashmi17-Jul-12 15:48
Syed J Hashmi17-Jul-12 15:48 
Generalthis can be done using EntLib Logging and Exception Handling App Block Pin
Esam Salah25-Jan-08 9:49
Esam Salah25-Jan-08 9:49 
GeneralRe: this can be done using EntLib Logging and Exception Handling App Block Pin
Anders Revsgaard3-Feb-08 0:56
Anders Revsgaard3-Feb-08 0:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.