Is there a way to get ULS Logs from all servers in a farm in wss or moss. I need to obtain logs programmatically using C#. I can get logs from one server in a farm, but I need all of them. Any help appreciated.
You could use the ULS Viewer: http://ulsviewer.codeplex.com/
Or you could write your own logging service using SPDiagnosticsService
http://msdn.microsoft.com/en-us/library/gg512103.aspx
Edit from the comments:
To read files directly you could do:
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