Uls – Unified Logging Service

http://blog.mastykarz.nl/logging-uls-sharepoint-2010/

SP 2007 has Unified Logging Service (ULS) but ULS was for internal use only and was not supposed to be used in custom code. SharePoint 2010 changes this situation: using the new ULS is now supported and may be used for logging in custom code.

This is how:

try

{

    var i = 0;

    var a = 2 / i;

}

catch (Exception ex)

{

    SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(“My Category”,
TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);

}

——————————————————————————————————-

On SP 2010, you can configure ULS logging setting: (1) default location ofr log files, (2) max. number of log files and (3) duration of time (in minutess) that each log file covers.

The log fle settings apply all servers in the farm.

To configure ULS in Sharepoint 2010, go to Central Administration à Monitoring à Reporting à Configure usage and health data collection.

The log path loo like:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS

Sharepoint doesn’t have built-in log viewer.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: