IronPDF 中的原生例外處理

This article was translated from English: Does it need improvement?
Translated
View the article in English

在 IronPdf 的近期版本中,日誌中的原生例外訊息將包含一個特定的問題代碼:[問題代碼 IronPdf-NATIVE-EXCEPTION]。 此類例外訊息的範例如下所示:

IronPdf.Exceptions.IronPdfNativeException: Error while generating PDF from HTML: 'Error while rendering pdf from html for job group 0: 'Error during dev tools execution: {"method":"Inspector.targetCrashed","params":{}}''.
2024-01-25 08:12:11,960 INFO  [Thread-3] [, , , , , , , , ] c.i.i.i.s.Access: [IronPdfEngine] To learn how to solve this issue please read https://ironpdf.com/troubleshooting/ironpdf-native-exception [Issue Code IRONPDF-NATIVE-EXCEPTION]

可能原因

IronPDF 的原生例外狀況通常源於 IronPdf.Native.Chrome 套件中使用的 C++ 程式碼所引發的各種問題,該套件是 IronPDF 的依賴項,並涉及 Chrome PDF 渲染引擎的使用。

解決方案

若需針對原生例外狀況尋求協助,請提交工程支援請求,並提供完整的日誌檔案以供進一步調查。

請在您的專案中加入以下程式碼片段,以啟用原生記錄功能:

// Set the path for the log file. 
// This can be a directory name or a specific file path. Here, we set it to "Default.log".
IronPdf.Logging.Logger.LogFilePath = "Default.log";

// Enable logging for all modes to capture comprehensive details
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;
// Set the path for the log file. 
// This can be a directory name or a specific file path. Here, we set it to "Default.log".
IronPdf.Logging.Logger.LogFilePath = "Default.log";

// Enable logging for all modes to capture comprehensive details
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;
' Set the path for the log file. 
' This can be a directory name or a specific file path. Here, we set it to "Default.log".
IronPdf.Logging.Logger.LogFilePath = "Default.log"

' Enable logging for all modes to capture comprehensive details
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All
$vbLabelText   $csharpLabel

IronPDF 所建立的日誌檔案通常位於您專案中部署 DLL 的 /bin 目錄下,您亦可設定自訂 IronPdf.Logging.Logger.LogFilePath 參數,將日誌檔案儲存至特定位置。 相關日誌檔案包括:

  • Default.log:包含有關部署、執行緒及渲染流程的資訊。 這對於觀察流程行為和例外狀況非常有用。
  • cef.log:包含 Chrome Embedded Framework 進程的日誌。

請注意在舊版 IronPdf 中,日誌檔案也可能包含 IronSoftwareEngine.log。 請提交所有在請求工程支援時產生的日誌檔案。)}]

對於雲端伺服器,日誌檔案可能位於特定目錄中。 請參閱我們的指南,了解如何在 AzureAWS 中產生日誌檔案。

Curtis Chau
技術撰稿人

Curtis Chau 擁有卡爾頓大學(Carleton University)的電腦科學學士學位,專精於前端開發,並精通 Node.js、TypeScript、JavaScript 及 React。他熱衷於打造直觀且美觀的用戶介面,喜歡運用現代框架,並創建結構完善、視覺上吸引人的手冊。

除了開發工作之外,Curtis 對物聯網(IoT)抱有濃厚興趣,致力於探索整合硬體與軟體的創新方法。閒暇時,他喜歡玩遊戲和開發 Discord 機器人,將對科技的熱愛與創意相結合。

準備開始了嗎?
Nuget 下載 19,014,616 | 版本: 2026.5 just released
Still Scrolling Icon

還在往下捲動嗎?

想要快速確認成果嗎? PM > Install-Package IronPdf
執行範例 觀看您的 HTML 轉為 PDF。