AWS Lambda出现意外的行为

我做了什么

我使用aws-kotlin-jvm-maven模板创建了一个使用无服务器cli的项目。 之后,我用这种方式编辑了我的serverless.yml模板:

 service: test provider: name: aws runtime: java8 region: eu-west-1 package: artifact: target/test-1.0.0.jar functions: hello: handler: com.example.Handler events: - schedule: rate(2 minutes) 

我已经这样编辑我的Handler:

 class Handler:RequestHandler<Map, ApiGatewayResponse> { override fun handleRequest(input:Map, context:Context):ApiGatewayResponse { BasicConfigurator.configure() LOG.info("Hello, World!") return ApiGatewayResponse() } companion object { private val LOG = Logger.getLogger(Handler::class.java) } } 

我期待着我的Lambda每两分钟运行一次,记录一个“Hello,World!” 在CloudWatch上,每2分钟一次。

我的问题

我在cloudWatch日志中find的是以下内容:

第一轮:“你好,世界!”

第二轮:“你好,世界!” “你好,世界!”

第三轮:“你好,世界!” “你好,世界!” “你好,世界!”

…等等。

有什么建议在这里发生了什么?

我通过将日志依赖性更改为:

  io.symphonia lambda-logging 1.0.0  

我在这里find了一篇非常有用的文章: https : //blog.symphonia.io/a-love-letter-to-lambda-logging-974b0eb49273