2011-01-12 57 views
1

我安装了一个功能,我的生产环境,但现在它抛出以下错误:如何获取更多信息到我的SharePoint日志中?

The Execute method of job definition SharePointSocialNetworking.Facebook (ID 528d61e4-95b6-4766-bb98-4363da570506) threw an exception. More information is included below. Object reference not set to an instance of an object.

Exception stack trace: at SharePointSocialNetworking.Facebook.Execute(Guid targetInstanceId) at Microsoft.SharePoint.Administration.SPTimerJobInvoke.Invoke(TimerJobExecuteData& data, Int32& result)

我的问题是,我的堆栈跟踪停止只是因为它是越来越有用......我需要知道在执行方法是错误的(甚至可能是行号)。他们只是给我足够的信息,有一个普遍的想法是什么问题,但不是发生在哪里...

有没有地方得到一个完整的堆栈跟踪或确切地追查我的“对象引用不是设置为一个对象的实例。“错误正在发生?

在我的中央管理员的“诊断日志记录”部分中,我将“设置为”错误“和”报告到跟踪日志的最低关键事件“设置为”详细“ 。

这是一个计时器工作。

回答

1

因为你的PDBS不得到打包和部署,你不能从你的异常

How can I include line numbers in a stack trace without a pdb?

得到行号,但我得到它周围建设一个“消息”作为一个过程发生,你知道在哪里错误发生是因为'消息'中的值。

所有我的SharePoint作业结构与此类似:

public class CustomJob : SPJobDefinition { 
    public override void Execute() { 
     try { 
      WriteTrace("CustomJob.Execute:"); 
      Process(); 
      WriteTrace("CustomJob.Execute[end]"); 
     } catch (Exception ex) { 
      WriteTrace(string.Format("CustomJob.Execute\nException: {0}", ex)); 
     } 
    } 
    public void Process() { 
     string message = "CustomJob.Process\n"; 
     try { 
      //do something 
      message += "value1: " + value1 + "\n"; 
      //do something 
      message += "value2: " + value2 + "\n"; 
      //do something 
      message += "value3: " + value3 + "\n"; 
     } catch (Exception ex) { 
      WriteTrace(string.Format("CustomJob.Process\nException: {0}", ex)); 
     } 
     WriteTrace(message); 
    } 
    private void WriteTrace(string message) { 
     //configure how you need, either write to ULS or write to event log 
     SPDiagnosticsService.Local.WriteTrace(0, 
      new SPDiagnosticsCategory("My Category", 
      TraceSeverity.Unexpected, 
      EventSeverity.Error), 
      TraceSeverity.Unexpected, message, ex.StackTrace); 
    } 
} 

这让我相当准确地跟踪最错误的开发和生产

编辑

有写方式到2007年的跟踪记录(确实更复杂)

http://weblogs.asp.net/erobillard/archive/2008/07/31/sharepoint-trace-logs-and-the-unified-logging-service-uls.aspx

http://msdn.microsoft.com/en-us/library/aa979522%28v=office.12%29.aspx

http://weblogs.asp.net/gunnarpeipman/archive/2009/02/25/sharepoint-writing-messages-to-uls-unified-logging-system.aspx

但我只是直接写在事件日志中:

 EventLog el1 = new EventLog(); 
     el1.Source = "My Custom Source"; 
     el1.WriteEntry(message, EventLogEntryType.Information); 
+0

如果我使用SP 2007,我会如何写入跟踪日志? `WriteTrace`似乎只适用于SP 2010 ... – 2011-01-12 22:24:04

+0

完美运作。无论如何,我讨厌试图阅读SP日志。 – 2011-01-14 18:31:51

0

如果其自定义的计时器作业,你为什么不通过附加调试它交互owstimer.exe。见调试计时器作业:

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

关于你的跟踪问题,您可以登录Exception对象的字符串StackTrace财产跟踪日志由其他职位所示。