IronPDF中AWS日誌檔案的疑難排解

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

使用S3 Bucket隔離IronPDF日誌

當在AWS環境中進行IronPDF疑難排解時,獲取來自IronPDF程式庫的乾淨、專用日誌是非常有幫助的。 此方法有助於避免從Amazon CloudWatch Logs或AWS Application Insights等服務中挑選合併的日誌流的複雜性。

服務如CloudWatch Logs和Application Insights通常會彙總來自各種來源的日誌,包括您的應用程式碼、其他程式庫和AWS服務。 這種交錯可能使得直接找出IronPDF特定的消息並診斷與PDF生成或操作相關的問題變得困難。

為了克服這些挑戰,我們建議配置IronPDF將其日誌寫入您AWS計算環境的臨時儲存中的專用檔案中。 此獨立的日誌檔案可以輕鬆上傳到Amazon S3 Bucket,以便需要時方便下載、審查和與支援分享。

啟用和配置IronPDF日誌

var awsTmpPath = @"/tmp/";

IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All;
IronSoftware.Logger.LogFilePath = awsTmpPath + "default.txt";
var awsTmpPath = @"/tmp/";

IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All;
IronSoftware.Logger.LogFilePath = awsTmpPath + "default.txt";
Dim awsTmpPath = "/tmp/"

IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All
IronSoftware.Logger.LogFilePath = awsTmpPath & "default.txt"
$vbLabelText   $csharpLabel

將日誌檔案上傳到Amazon S3 Bucket

// File path in the Lambda /tmp directory
var filePath = $"/tmp/default.txt";

// Read the file as byte array
var fileBytes = await File.ReadAllBytesAsync(filePath);

// Upload the text file to S3
using (var memoryStream = new MemoryStream(fileBytes))
{
    var request = new PutObjectRequest
    {
        BucketName = bucketName,
        Key = "default.txt",
        InputStream = memoryStream,
        ContentType = "text/plain",
    };

    await _s3Client.PutObjectAsync(request);
}
// File path in the Lambda /tmp directory
var filePath = $"/tmp/default.txt";

// Read the file as byte array
var fileBytes = await File.ReadAllBytesAsync(filePath);

// Upload the text file to S3
using (var memoryStream = new MemoryStream(fileBytes))
{
    var request = new PutObjectRequest
    {
        BucketName = bucketName,
        Key = "default.txt",
        InputStream = memoryStream,
        ContentType = "text/plain",
    };

    await _s3Client.PutObjectAsync(request);
}
' File path in the Lambda /tmp directory
Dim filePath = $"/tmp/default.txt"

' Read the file as byte array
Dim fileBytes = Await File.ReadAllBytesAsync(filePath)

' Upload the text file to S3
Using memoryStream As New MemoryStream(fileBytes)
	Dim request = New PutObjectRequest With {
		.BucketName = bucketName,
		.Key = "default.txt",
		.InputStream = memoryStream,
		.ContentType = "text/plain"
	}

	Await _s3Client.PutObjectAsync(request)
End Using
$vbLabelText   $csharpLabel

關於AWS特定的日誌服務,請參閱以下文件:

Amazon CloudWatch

Amazon CloudWatch Logs服務允許您幾乎實時地收集和儲存來自您的資源、應用程式和服務的日誌。

額外日誌

關於Amazon CloudWatch Logs、Amazon S3 Logs以及發送到Kinesis Data Firehose的日誌的更多資訊,請參閱:

https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html

常見服務

AWS Lambda

https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html

Amazon EC2

https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html

Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

除了開發,Curtis對物聯網(IoT)有濃厚的興趣,探索創新的方法來整合硬體和軟體。在空閒時間,他喜歡玩遊戲和建立Discord機器人,結合他對技術的熱愛與創造力。

準備開始了嗎?
Nuget 下載 20,296,129 | 版本: 2026.7 剛剛發布
Still Scrolling Icon

還在捲動嗎?

想快速獲得證明嗎? PM > Install-Package IronPdf
執行範例 看您的HTML變成PDF。