.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Advantage of ULS Logging in SharePoint

Posted By:Jean Paul       Posted Date: April 24, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

Logging Information is required for Debugging in Production Deployments. In this article I would compare the usage of SharePoint ULS Logging along with regular Text File Logging.
 

Logging Information is required for Debugging in Production Deployments. In this article I would compare the usage of SharePoint ULS Logging along with regular Text File Logging.

ULS Logging Here we are using SPDiagnostics class for logging information.

Text Logging Here we are using a TextWriter and writing information to file.

uls log

Advantages of ULS Logging

Following are the advantages of ULS Logging:

1. Log Information can be controlled through Central Administration.

2. Built-in classes for writing log information.

3. Sophisticated Tools available for viewing log entries

While writing ULS Log Information, we need to specify Trace Severity & Event Severity.

image

Through Central Administration, we can control the Trace & Event Severity. Open Configure diagnostic logging from central administration.

image

You can filter the log information based on severity there:

image

Thus, even though our code will contain the Log Writing code, the actual writing only takes place based on the severity level allowed through Central Administration.

This gives the advantage of:

1. Turning On writing to log file through Central Administration when required

2. Turning Off writing to log file when debugging is completed

Sample ULS Logging Code

Following is a test logging code with Trace Severity as High.

SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("Application", TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, "Message here");

Following is a test logging code with Trace Severity as Verbose.

SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("Application", TraceSeverity. Verbose, EventSeverity.Error), TraceSeverity.Verbose, "Big Message here");

Verbose severity is used to log too much information, for example writing the internal data structure for debugging purpose.

image

Although Verbose log writing code resides in the Production Deployed Assembly, it will not impact performance when the Central Administration settings is set to exclude Verbose logging.

ULS Log Viewer

You can download the ULS Log Viewer for more convenient viewing of ULS Log information.

image

You can download from:

http://archive.msdn.microsoft.com/ULSViewer

References

http://msdn.microsoft.com/en-us/library/ff512738(v=office.14).aspx

Summary

In this article we have explored the advantages of using ULS Logging in SharePoint. In real world scenarios this provides more convenience & control in the amount of information logged. You can also use ULS Log Viewer for more flexible viewing options.v


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend