c# - ULS 登录 sharepoint 2007

标签 c# .net sharepoint logging sharepoint-2007

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

最佳答案

您可以使用 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

关于c# - ULS 登录 sharepoint 2007,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10738067/

相关文章:

c# - RegisterCollection 来自以前使用简单注入(inject)器注册的类型

c# - 在 .Net 中锁定 - 是引用锁定还是对象锁定?

jquery - e.preventdefault();不工作

powershell - 循环访问多个 SharePoint 网站集

c# - 通过抛出异常而不是返回来完成方法

c# - boolean 逻辑规则评估器

c# - LINQ:给定一个对象列表,创建一个以子对象为键、以父对象为值的字典

.net - ResourceManager 试图加载 .resources 而不是 .resx 文件

c# - 如何在不手动指定编码的情况下在 C# 中获得字符串的一致字节表示?

c# - Sharepoint Web 服务项目数据(访问 "Created By"列)