swift-server / swift-aws-lambda-runtime

Swift implementation of AWS Lambda Runtime
Apache License 2.0
1.13k stars 102 forks source link

How to view log messages #180

Closed Peter-Schorn closed 3 years ago

Peter-Schorn commented 3 years ago

I'm having a little trouble figuring out how to see the logs for my function. Within my lambda function, at the very beginning, I have the following:

Lambda.run { (
    context: Lambda.Context,
    request: APIGateway.V2.Request,
    callback: @escaping (Result<APIGateway.V2.Response, Error>) -> Void
) in

    let message = "redirectURI: \(redirectURI); " +
        "rawQueryString: \(request.rawQueryString)"
    print(message)
    context.logger.error("\(message)")

    // ...

}

I also set the LOG_LEVEL environment variable to trace.

I went to the cloud watch console, as described in the user guide and selected "Log Groups" from the navigation pane and selected the log group for my function. Yet, I do not see any of the log messages that I created.

Screen Shot 2020-12-22 at 8 55 41 PM

I apologize if this is the wrong place to ask this question, but I could not find any helpful information anywhere else.

tomerd commented 3 years ago

@Peter-Schorn sorry for the slow response. logging with context.logger.error should work out of the box. are you still experiencing this issue?

Peter-Schorn commented 3 years ago

Thanks for your response. I am no longer experiencing any issues. I discovered that it takes 5-10 minutes for log messages to show up in the cloud watch console.

fabianfett commented 3 years ago

@Peter-Schorn Do you mind of we close this issue now?