Fehlerbehebung bei AWS-Protokolldateien in IronPDF
Isolation von IronPDF-Protokollen mit S3-Bucket
Bei der Fehlerbehebung bei Problemen mit IronPDF in einer AWS-Umgebung ist es von großem Nutzen, saubere, dedizierte Protokolle direkt aus der IronPDF-Bibliothek zu erhalten. Dieser Ansatz hilft, die Komplexität des Durchsuchens von zusammengeführten Protokollströmen aus Diensten wie Amazon CloudWatch Logs oder AWS Application Insights zu vermeiden.
Dienste wie CloudWatch Logs und Application Insights aggregieren typischerweise Protokolle aus verschiedenen Quellen, einschließlich Ihres Anwendungscodes, anderer Bibliotheken und AWS-Dienste. Diese Verflechtung kann es erschweren, IronPDF-spezifische Nachrichten zu identifizieren und Probleme im Zusammenhang mit der PDF-Erzeugung oder -Manipulation direkt zu diagnostizieren.
Um diese Herausforderungen zu überwinden, empfehlen wir, IronPDF so zu konfigurieren, dass es seine Protokolle in einer dedizierten Datei im temporären Speicher Ihrer AWS-Compute-Umgebung schreibt. Diese isolierte Protokolldatei kann dann problemlos in einen Amazon S3-Bucket hochgeladen werden, um sie bequem herunterzuladen, zu überprüfen und bei Bedarf mit dem Support zu teilen.
IronPDF-Protokollierung aktivieren und konfigurieren
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"
Laden Sie die Protokolldatei in einen Amazon S3-Bucket hoch
// 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
Für AWS-spezifische Protokollierungsdienste beachten Sie bitte die folgende Dokumentation:
Amazon CloudWatch
Der Amazon CloudWatch Logs-Dienst ermöglicht es Ihnen, Protokolle von Ihren Ressourcen, Anwendungen und Diensten nahezu in Echtzeit zu sammeln und zu speichern.
Zusätzliche Protokollierung
Für weitere Informationen zu Amazon CloudWatch Logs, Amazon S3 Logs und an den Kinesis Data Firehose gesendete Protokolle lesen Sie bitte:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html
Gemeinsame Dienste
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

