Skip to content

How to get access to Lamba logs #8045

Answered by bblommers
RajasGujarathi asked this question in Q&A
Discussion options

You must be logged in to vote

Logs are stored in CloudWatch, just like they are in AWS. In our tests we use the following code to get the results from an asyncronous invocation:

logs_conn = boto3.client("logs", region_name="us-east-1")

start = time.time()
while (time.time() - start) < 30:
    result = logs_conn.describe_log_streams(logGroupName=f"/aws/lambda/{fn_name}")
    log_streams = result.get("logStreams")
    if not log_streams:
        time.sleep(0.5)
        continue
    assert len(log_streams) >= 1

    result = logs_conn.get_log_events(
        logGroupName=f"/aws/lambda/{fn_name}",
        logStreamName=log_streams[0]["logStreamName"],
    )
    print(result)
    for event in result.get("events"):
       …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by RajasGujarathi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants