Showing posts with label sharepoint logs. Show all posts
Showing posts with label sharepoint logs. Show all posts

Monday, March 28, 2011

Accessing SharePoint 2010 Logging Database

By default, the database is called WSS_Logging should be the starting point for administrators and developers to collect and analyse information. The following demonstrates how to access the database and run a view (that already is installed) against it.

  • Open up SQL Server Management Studio
  • When asked for authentication, log in to the correct instance where SharePoint is running using your windows authentication credentials
  • Navigate to the WSS_Logging database and click on the plus sign to expand it as shown in figure below:

image

  • Under the toolbar at the top, click on the New Query button
  • In the new query window, type in the following query:

SELECT * FROM RequestUsage

  • Click Execute.
  • Results are populated in the window pane below the query, as seen in the following screenshot:

image

RequestUsage is an out of the box view that provides site usage information. It provides information such as the referring URL, the browser being used, the site ID, the web ID, the server URL, the request type, and when it was done. There are 24 views installed by default as shown in figure below:

image

The logging database contains, but is not limited to, the following information:

  • ULS logs
  • NT event logs
  • Performance counters
  • Feature usage
  • Blocking queries
  • Site usage
  • Timer job information

Tuesday, January 4, 2011

Write Error Logging Entries To The SharePoint Unified Logging Service (ULS) Logs

All SharePoint exceptions are derived from the SPException class. We can write error logging entries to the SharePoint Unified Logging Service (ULS) logs by using code similar to the following sample:

using Microsoft.SharePoint.Administration;
 

try
{
    // Some code
}
catch (Exception ex)
{
    // Create diagnostics category
    SPDiagnosticsCategory oCat = new SPDiagnosticsCategory("A new category", TraceSeverity.Monitorable, EventSeverity.Error);
    // Write to ULS
    SPDiagnosticsService.Local.WriteEvent(1, oCat, EventSeverity.Error, "Error custom message", ex.StackTrace);
}

ULS is stored in the file system in “C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\LOGS”.