ULS logs in sharepoint 2007

Is there any way to get ULS logs from all farm servers in wss or moss. I need to get the logs programmatically using C #. I can receive logs from one server on the farm, but I need all of them. Any help was appreciated.

+3
source share
1 answer

You can use ULS Viewer: http://ulsviewer.codeplex.com/

Or you can write your own logging service using SPDiagnosticsService

http://msdn.microsoft.com/en-us/library/gg512103.aspx

Edit Comment:

To read files directly, you can:

   try 
    {
        // Create an instance of StreamReader to read from a file.
        // The using statement also closes the StreamReader.
        using (StreamReader sr = new StreamReader("FilePath:\\SharePointlogfile.uls")) 
        {
            string line;
            // Read and display lines from the file until the end of 
            // the file is reached.
            while ((line = sr.ReadLine()) != null) 
            {
                Console.WriteLine(line);
            }
        }
    }
    catch (Exception e) 
    {
        // Let the user know what went wrong.
        Console.WriteLine("The file could not be read:");
        Console.WriteLine(e.Message);
    }

http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx

+4
source

All Articles