Skip to content

Commit

Permalink
Patch by tawee80 for custom log location detection
Browse files Browse the repository at this point in the history
  • Loading branch information
hasankhan committed May 18, 2014
1 parent f14cbca commit 74832ad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions SharePointLogViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.6.2.0")]
[assembly: AssemblyFileVersion("2.6.2.0")]
[assembly: AssemblyVersion("2.6.3.0")]
[assembly: AssemblyFileVersion("2.6.3.0")]
22 changes: 20 additions & 2 deletions SharePointLogViewer/SPUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,13 @@ public static ICollection TraceSeverities
public static string GetLogsLocation()
{
string logLocation = String.Empty;

if (IsWSSInstalled)
{
logLocation = GetSPDiagnosticsLogLocation();
if (logLocation == String.Empty)
if (String.IsNullOrEmpty(logLocation))
logLocation = GetCustomLogLocation();
if (String.IsNullOrEmpty(logLocation))
logLocation = GetStandardLogLocation();
}

Expand Down Expand Up @@ -232,6 +235,21 @@ private static string GetStandardLogLocation()
return logLocation;
}

static string GetCustomLogLocation()
{
string logLocation = String.Empty;
try
{
using (RegistryKey key = GetWSSRegistryKey())
if (key != null)
using (RegistryKey subKey = key.OpenSubKey("WSS"))
if (subKey != null)
logLocation = subKey.GetValue("LogDir") as string;
}
catch (SecurityException) { }
return logLocation;
}

private static string GetSPDiagnosticsLogLocation()
{
string logLocation = String.Empty;
Expand All @@ -254,4 +272,4 @@ private static string GetSPDiagnosticsLogLocation()
return logLocation;
}
}
}
}

0 comments on commit 74832ad

Please sign in to comment.