Microsoft.SharePoint.Linq.DataContext 日志记录
我尝试将 Microsoft.SharePoint.Linq.DataContext 的 SharePoint CAML 查询记录到 System.Console.Log。
Microsoft.SharePoint.Linq.DataContext dataContext = new GeneraliETSPSDataContext(siteUrl);
dataContext.Log = System.Console.Out;
没有成功,Visual Studio 输出窗口中没有输出。 我无法从 VS 启动调试,我必须附加到 w3wp.exe,因为该项目已部署到 SPS 才能运行。
我做错了什么吗?关于记录 DataContext 的作用有什么建议吗?
I try to log SharePoint CAML queries of Microsoft.SharePoint.Linq.DataContext to System.Console.Log.
Microsoft.SharePoint.Linq.DataContext dataContext = new GeneraliETSPSDataContext(siteUrl);
dataContext.Log = System.Console.Out;
No success, no output in Visual Studio Output window.
I cannot start the debug from VS, I have to attach to w3wp.exe, sice the project is deployed to SPS to run.
Am I doing something wrong? Any tips on logging what DataContext does?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否针对 SharePoint 站点编写了任何 linq 查询?
类似于:
请记住,LINQ 查询始终在迭代查询变量时执行,而不是在创建查询变量时执行。
仅当您迭代结果或通过使用结果将其转换为列表来强制执行时,才会执行上述查询.ToList()
根据您的实际需求,一般有多种记录数据上下文查询或异常的方法。您可以将信息记录到 SharePoint ULS 日志、文本文件、SharePoint 列表(不推荐),甚至 SharePoint 库中的文档。
Did you write any linq queries against the SharePoint Site?
something like:
Remember, LINQ queries are always executed when the query variable is iterated over, not when the query variable is created
The above query only gets executed when you iterate over the results or force it to execute by converting it into a list using results.ToList()
Depending on your actual requirement, there are several ways of logging datacontext queries or exceptions in general. You can log info to SharePoint ULS Logs, to a text file, to a SharePoint list(not recommended), or even to a document in a SharePoint library.
您想在哪里记录实际输出? System.Console.Out 只会将文本编写器返回到不存在的控制台。
如果你想在sharepoint中登录ULS日志,你可以很容易地做到这一点,这里有一个简单的教程。 http://blog.mastykarz.nl/logging-uls-sharepoint-2010/
where do you want to log the actual output? System.Console.Out will just return a text writer to a non existant console.
If you want to log to the ULS logs in sharepoint you can do it very easily, here is a simple tutorial. http://blog.mastykarz.nl/logging-uls-sharepoint-2010/