2011-01-12 63 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財產跟蹤日誌由其他職位所示。

相關問題