0

I need to access ULS log path location from central administration through programmatically.

I used below code for get folder of logs and able to read all the logs text files.

  string logfolder = SPUtility.GetGenericSetupPath("LOGS");

Above code is worked, I just changed Trace Log location to "C:\Logs" from Central Administration > Monitoring > Configure diagnostic logging.

Seem like all new ULS Logs append into C:\Logs new location so I would like to read this value from Central administration through Code Because GenericSetupPath always give us to C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\LOGS.

Please guild me if any suitable solution it would be big helpful to me.

1 Answer 1

2

please look at this link, it shows how to achieve what you're trying to do.

using System;
using Microsoft.SharePoint.Administration;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
             SPDiagnosticsService diagSvc = SPDiagnosticsService.Local;
             string ulsLogLocation = diagSvc.LogLocation;
             Console.WriteLine(ulsLogLocation);

             Console.Write("\nPress ENTER to continue...");
             Console.ReadLine();
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.