localstack-logs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LocalStack 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
undefined
bash
undefined

Follow 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
undefined
docker logs localstack-main -f docker logs localstack-main --tail 200
undefined

Filtering Logs

过滤日志

bash
undefined
bash
undefined

Filter 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"
undefined
localstack logs | grep "request-id-here"
undefined

Debug Mode

调试模式

Enable detailed logging:
bash
undefined
启用详细日志记录:
bash
undefined

Start 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
undefined
LS_LOG=trace localstack start -d
undefined

Analyzing 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 => 200
LocalStack日志中包含AWS API请求信息。可查找如下格式的日志:
AWS <service>.<operation> => <status>
日志示例:
AWS s3.CreateBucket => 200
AWS dynamodb.PutItem => 200
AWS lambda.Invoke => 200

Common Error Patterns

常见错误模式

ErrorPossible CauseSolution
ResourceNotFoundException
Resource doesn't existCreate the resource first
AccessDeniedException
IAM policy issueCheck IAM enforcement mode
ValidationException
Invalid parametersVerify request parameters
ServiceException
Internal errorCheck LocalStack logs for details
错误可能原因解决方法
ResourceNotFoundException
资源不存在先创建对应的资源
AccessDeniedException
IAM策略问题检查IAM强制模式
ValidationException
参数无效验证请求参数是否正确
ServiceException
内部错误查看LocalStack日志获取详细信息

Lambda Debugging

Lambda调试

View Lambda Logs

查看Lambda日志

bash
undefined
bash
undefined

Lambda 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>
undefined
awslocal logs describe-log-groups awslocal logs get-log-events
--log-group-name /aws/lambda/my-function
--log-stream-name <stream-name>
undefined

Enable Lambda Debug Mode

启用Lambda调试模式

bash
LAMBDA_DEBUG=1 localstack start -d
bash
LAMBDA_DEBUG=1 localstack start -d

Health Check

健康检查

bash
undefined
bash
undefined

Check overall health

Check overall health

Check specific service

Check specific service

undefined
undefined

Troubleshooting Tips

排查技巧

  • No logs appearing: Ensure LocalStack is running (
    localstack status
    )
  • Missing debug info: Enable
    DEBUG=1
    for verbose logging
  • 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
  • 间歇性错误:排查资源限制或时序问题