AWS Lambda: Python logging
Log to local Python interpreter when test locally
1 | logging.basicConfig(level=logging.INFO) |
But this will not log to Cloud Watch when test on the cloud.
Log to Cloud Watch
AWS Lambda Python runtime has pre-configured log handlers. To log to Cloud Watch:
1 | logger = logging.getLogger() |
But this will not log to local Python interpreter when test locally.
Log to both Cloud Watch and local
1 | # If there is no pre-configured log handler, we set basicConfig |