在 IronPDF 中排除 AWS 日志文件故障
使用S3存储桶隔离IronPDF日志
在AWS环境中排除IronPDF问题时,获得来自IronPDF库的干净、专用日志非常有益。 这种方法有助于避免从Amazon CloudWatch Logs或AWS Application Insights等服务合并日志流中筛选的复杂性。
CloudWatch Logs和Application Insights等服务通常会汇总来自各种来源的日志,包括您的应用程序代码、其他库和AWS服务。 这种交错可能使得很难直接定位IronPDF特定的消息并诊断与PDF生成或操作相关的问题。
为了解决这些挑战,我们建议配置IronPDF将其日志写入AWS计算环境的临时存储中的专用文件。 然后可以轻松将此隔离的日志文件上传到Amazon S3存储桶,以便需要时便捷地下载、查看和与支持共享。
启用和配置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"将日志文件上传到Amazon S3存储桶
// 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对于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






