こんにちは、虎塚です。 AWS LambdaのログをCloudWatch Logsに出力している場合、ログをフィルタリングして利用することがあります。ログをアドホックに検索するだけなら気にしなくてもよいのですが、ログのレベルやメッセージ内容をもとに大事な後続処理を動かしたい場合は、デフォルトのログフォーマットを整形してから使います。これは、もし処理系の設定が変わってしまっても、Lambdaを組み込んだシステムが問題なく動くようにするためです。 この記事では、Lambda関数をPythonで書くときに、loggerのフォーマットを変える方法を記述します。 設定と動作確認 AWS Management Consoleにログインして、AWS Lambda Dashboardを開きます。Lambda関数一覧の画面で、[Create a Lambda function]ボタンをクリックします。 Bl