Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda Python Log Level basicConfig needs special initialisation #644

Open
alexiswl opened this issue Nov 3, 2024 · 0 comments
Open

Lambda Python Log Level basicConfig needs special initialisation #644

alexiswl opened this issue Nov 3, 2024 · 0 comments
Assignees
Labels
bug Something isn't working pipeline Workflow/Pipeline Manager

Comments

@alexiswl
Copy link
Member

alexiswl commented Nov 3, 2024

Python Lambda Logger is a little odd

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

logger.info("Foo")

Won't print 'foo' to the cloudwatch logs,

This stack overflow answer explains it a little more

From this stack overflow answer on the same thread, we see the comment that since python 3.8 we can just use the force=True on basicConfig.

From https://docs.python.org/3/library/logging.html#logging.basicConfig:

This function does nothing if the root logger already has handlers configured, unless the keyword argument force is set to True.

So action is to set force as 'true' to logging.basicConfig.

We should probably also use format='%(asctime)s %(message)s' to provide timestamps in the cloudwatch logs of when logs were printed

@alexiswl alexiswl self-assigned this Nov 3, 2024
@alexiswl alexiswl added the bug Something isn't working label Nov 3, 2024
alexiswl added a commit that referenced this issue Nov 3, 2024
@victorskl victorskl added the pipeline Workflow/Pipeline Manager label Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pipeline Workflow/Pipeline Manager
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants