Getting SharePoint ULS Log Location Without Reverting To Literals

The ULS logs are pretty great, especially when you have pre-existing, non-development dependent errors occurring that make absolutely freakin no sense. It’s pretty easy to get the path using the SPDiagnosticsService object.

[csharp]

public string ULSPath()
{
try
{
return SPDiagnosticsService.Local.LogLocation;
}
catch (SqlException sqlEx)
{
SPDiagCommonHelper.TraceException(sqlEx);
}
catch (SPException spEx)
{
SPDiagCommonHelper.TraceException(spEx);
}
return string.Empty;
}
[/csharp]

Share

2 thoughts on “Getting SharePoint ULS Log Location Without Reverting To Literals”

Leave a Reply

Your email address will not be published. Required fields are marked *