Can't get AWS Lambda function to log (text output) to CloudWatch

后端 未结 15 512
独厮守ぢ
独厮守ぢ 2020-12-13 12:14

I\'m trying to set up a Lambda function that will process a file when it\'s uploaded to an S3 bucket. I need a way to see the output of console.log when I uploa

15条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 12:32

    It might already log, we just couldn't find the logs we expect...

    e.g.

    app.use(function simpleLogger (req, res, next) {
      console.info('[Logger]', req.method, req.originalUrl)
      next()
    })
    

    After performing GET /hello?world=1,

    Local console: (simple and clear, nice!)

    [Logger] GET /hello?world=1
    

    CloudWatch Logs: (can you easily find the exact log below?)

    START RequestId: a3552c34-f7a6-11e8-90ba-2fb886f31fb0 Version: $LATEST
    2018-12-04T09:26:11.236Z  a3552c34-f7a6-11e8-90ba-2fb886f31fb0  [Logger] GET /hello?world=1
    END RequestId: a3552c34-f7a6-11e8-90ba-2fb886f31fb0
    REPORT RequestId: a3552c34-f7a6-11e8-90ba-2fb886f31fb0  Duration: 41.02 ms  Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 29 MB
    

    Conclusion: too verbose to locate the original logs.

提交回复
热议问题