localstack-logs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLocalStack Logs Analysis
LocalStack 日志分析
Analyze LocalStack logs to debug issues, identify errors, and understand AWS API interactions.
分析LocalStack日志以调试问题、识别错误并理解AWS API交互过程。
Capabilities
功能特性
- View and filter LocalStack logs
- Identify error patterns and failures
- Analyze AWS API request/response cycles
- Track service-specific operations
- Debug Lambda function executions
- 查看并过滤LocalStack日志
- 识别错误模式与故障
- 分析AWS API请求/响应周期
- 追踪特定服务的操作
- 调试Lambda函数执行过程
Viewing Logs
查看日志
Basic Log Commands
基础日志命令
bash
undefinedbash
undefinedFollow logs in real-time
Follow logs in real-time
localstack logs -f
localstack logs -f
View last N lines
View last N lines
localstack logs --tail 100
localstack logs --tail 100
Via Docker
Via Docker
docker logs localstack-main -f
docker logs localstack-main --tail 200
undefineddocker logs localstack-main -f
docker logs localstack-main --tail 200
undefinedFiltering Logs
过滤日志
bash
undefinedbash
undefinedFilter by service
Filter by service
localstack logs | grep -i s3
localstack logs | grep -i lambda
localstack logs | grep -i dynamodb
localstack logs | grep -i s3
localstack logs | grep -i lambda
localstack logs | grep -i dynamodb
Filter errors only
Filter errors only
localstack logs | grep -i error
localstack logs | grep -i exception
localstack logs | grep -i error
localstack logs | grep -i exception
Filter by request ID
Filter by request ID
localstack logs | grep "request-id-here"
undefinedlocalstack logs | grep "request-id-here"
undefinedDebug Mode
调试模式
Enable detailed logging:
bash
undefined启用详细日志记录:
bash
undefinedStart with debug mode
Start with debug mode
DEBUG=1 localstack start -d
DEBUG=1 localstack start -d
Enable specific debug flags
Enable specific debug flags
LS_LOG=trace localstack start -d
undefinedLS_LOG=trace localstack start -d
undefinedAnalyzing API Requests
分析API请求
Request/Response Tracking
请求/响应追踪
LocalStack logs include AWS API requests. Look for patterns like:
AWS <service>.<operation> => <status>Example log entries:
AWS s3.CreateBucket => 200
AWS dynamodb.PutItem => 200
AWS lambda.Invoke => 200LocalStack日志中包含AWS API请求信息。可查找如下格式的日志:
AWS <service>.<operation> => <status>日志示例:
AWS s3.CreateBucket => 200
AWS dynamodb.PutItem => 200
AWS lambda.Invoke => 200Common Error Patterns
常见错误模式
| Error | Possible Cause | Solution |
|---|---|---|
| Resource doesn't exist | Create the resource first |
| IAM policy issue | Check IAM enforcement mode |
| Invalid parameters | Verify request parameters |
| Internal error | Check LocalStack logs for details |
| 错误 | 可能原因 | 解决方法 |
|---|---|---|
| 资源不存在 | 先创建对应的资源 |
| IAM策略问题 | 检查IAM强制模式 |
| 参数无效 | 验证请求参数是否正确 |
| 内部错误 | 查看LocalStack日志获取详细信息 |
Lambda Debugging
Lambda调试
View Lambda Logs
查看Lambda日志
bash
undefinedbash
undefinedLambda function logs appear in LocalStack logs
Lambda function logs appear in LocalStack logs
localstack logs | grep -A 10 "Lambda"
localstack logs | grep -A 10 "Lambda"
Or use CloudWatch Logs locally
Or use CloudWatch Logs locally
awslocal logs describe-log-groups
awslocal logs get-log-events
--log-group-name /aws/lambda/my-function
--log-stream-name <stream-name>
--log-group-name /aws/lambda/my-function
--log-stream-name <stream-name>
undefinedawslocal logs describe-log-groups
awslocal logs get-log-events
--log-group-name /aws/lambda/my-function
--log-stream-name <stream-name>
--log-group-name /aws/lambda/my-function
--log-stream-name <stream-name>
undefinedEnable Lambda Debug Mode
启用Lambda调试模式
bash
LAMBDA_DEBUG=1 localstack start -dbash
LAMBDA_DEBUG=1 localstack start -dHealth Check
健康检查
bash
undefinedbash
undefinedCheck overall health
Check overall health
curl http://localhost:4566/_localstack/health | jq
curl http://localhost:4566/_localstack/health | jq
Check specific service
Check specific service
curl http://localhost:4566/_localstack/health | jq '.services.s3'
undefinedcurl http://localhost:4566/_localstack/health | jq '.services.s3'
undefinedTroubleshooting Tips
排查技巧
- No logs appearing: Ensure LocalStack is running ()
localstack status - Missing debug info: Enable for verbose logging
DEBUG=1 - Lambda issues: Check both LocalStack logs and CloudWatch Logs
- Intermittent errors: Look for resource limits or timing issues
- 无日志输出:确保LocalStack正在运行(执行查看)
localstack status - 缺少调试信息:启用以获取详细日志
DEBUG=1 - Lambda问题:同时检查LocalStack日志和CloudWatch Logs
- 间歇性错误:排查资源限制或时序问题