2012-05-24 72 views
3

有没有办法从wss或苔藓中的服务器场中的所有服务器获取ULS日志。我需要使用C#以编程方式获取日志。我可以从服务器场中的一台服务器获取日志,但我需要所有这些日志。任何帮助赞赏。ULS登录sharepoint 2007

+0

http://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/1acfe853-5da7-4a4e-9097-d99b6dfd3b79我读过这篇文章,但它也没有为我工作。任何想法 – Alexandr

回答

4

您可以使用ULS查看:http://ulsviewer.codeplex.com/

或者您可以使用从评论SPDiagnosticsService

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

编辑写自己的日志服务:

直接读取文件,你可以做:

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

+0

的事情是,我需要得到日志编程,没有工具。对于wss 2007. – Alexandr

+2

您最好的选择是使用SPDiagnosticsService类并应用于农场级别。如果您的程序可以访问服务器场中的所有服务器,则可以使用简单的StreamReader直接读取文件,并将它指向每个服务器的{SharePoint Root} \ LOGS。 –

+0

我可以访问所有的服务器,但是您提供了一行代码。我不知道如何直接读取文件。提前致谢。 – Alexandr