# Troubleshooting AWS Log Files in IronPDF
## Isolating IronPDF Logs Using S3 Bucket
When troubleshooting issues with IronPDF in an AWS environment, obtaining clean, dedicated logs from the IronPDF library itself is highly beneficial. This approach helps avoid the complexities of sifting through merged log streams from services like Amazon CloudWatch Logs or AWS Application Insights.
Services like CloudWatch Logs and Application Insights typically aggregate logs from various sources, including your application code, other libraries, and AWS services. This interleaving can make it difficult to pinpoint IronPDF-specific messages and diagnose issues related to PDF generation or manipulation directly.
To overcome these challenges, we recommend configuring IronPDF to write its logs to a dedicated file within your AWS compute environment's temporary storage. This isolated log file can then be easily uploaded to an Amazon S3 bucket for convenient download, review, and sharing with support if needed.
## Enable and Configure IronPDF Logging
```cs
var awsTmpPath = @"/tmp/";
IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All;
IronSoftware.Logger.LogFilePath = awsTmpPath + "default.txt";
```
## Upload the Log File to an Amazon S3 Bucket
```cs
// 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);
}
```
----
For AWS-specific logging services, please refer to the following documentation:
## Amazon CloudWatch
The Amazon CloudWatch Logs service allows you to collect and store logs from your resources, applications, and services in near real-time.
- [https://aws.amazon.com/cloudwatch/](https://aws.amazon.com/cloudwatch/)
- [https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html)
- [https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/aws-services-sending-logs.html](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/aws-services-sending-logs.html)
## Additional Logging
For further information on Amazon CloudWatch Logs, Amazon S3 Logs, and logs sent to Kinesis Data Firehose, please see:
[https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html)
## Common Services
### AWS Lambda
[https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html](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](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html)
When troubleshooting issues with IronPDF in an AWS environment, obtaining clean, dedicated logs from the IronPDF library itself is highly beneficial. This approach helps avoid the complexities of sifting through merged log streams from services like Amazon CloudWatch Logs or AWS Application Insights.
Services like CloudWatch Logs and Application Insights typically aggregate logs from various sources, including your application code, other libraries, and AWS services. This interleaving can make it difficult to pinpoint IronPDF-specific messages and diagnose issues related to PDF generation or manipulation directly.
To overcome these challenges, we recommend configuring IronPDF to write its logs to a dedicated file within your AWS compute environment's temporary storage. This isolated log file can then be easily uploaded to an Amazon S3 bucket for convenient download, review, and sharing with support if needed.
Enable and Configure IronPDF Logging
var awsTmpPath = @"/tmp/";IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All;IronSoftware.Logger.LogFilePath = awsTmpPath + "default.txt";
// File path in the Lambda /tmp directoryvar filePath = $"/tmp/default.txt";// Read the file as byte arrayvar fileBytes = awaitFile.ReadAllBytesAsync(filePath);// Upload the text file to S3using (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 directoryDim filePath = $"/tmp/default.txt"' Read the file as byte arrayDim fileBytes = AwaitFile.ReadAllBytesAsync(filePath)' Upload the text file to S3Using memoryStream As New MemoryStream(fileBytes) Dim request = New PutObjectRequestWith { .BucketName = bucketName, .Key = "default.txt", .InputStream = memoryStream, .ContentType = "text/plain" }Await _s3Client.PutObjectAsync(request)EndUsing
' 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
For AWS-specific logging services, please refer to the following documentation:
Amazon CloudWatch
The Amazon CloudWatch Logs service allows you to collect and store logs from your resources, applications, and services in near real-time.
Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.