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 PowerShell Functions Do Not Log Debug Messages to CloudWatch Messages #1641

Closed
ashovlin opened this issue Dec 12, 2023 · 2 comments
Closed
Assignees
Labels
bug This issue is a bug. module/custom-runtime p2 This is a standard priority issue queued

Comments

@ashovlin
Copy link
Member

ashovlin commented Dec 12, 2023

Describe the bug

We already have internal case and ticket V1078993289 for this, but creating this so others can track a fix publicly.

Expected Behavior

"Write-Debug" should print to CloudWatch messages when adding -Debug parameter or using $DebugPreference to get the message displayed on console.

Current Behavior

Messages aren't logged.

Possible Solution

This probably is happening because "Write-Debug" isn't included in these events https://github.com/aws/aws-lambda-dotnet/blob/master/Libraries/src/Amazon.Lambda.PowerShellHost/PowerShellFunctionHost.cs#L294

@ashishdhingra
Copy link
Contributor

ashishdhingra commented Sep 30, 2024

The change has been released in AWSLambdaPSCore 4.0.2.0.

Kindly note the following to enable debugging:

  • Refer $DebugPreference. In PowerShell code, you:
    • Either need to set $DebugPreference = "Continue" at the beginning of script; OR
    • Include -Debug parameter while executing Write-Debug (e.g. Write-Debug "Testing Lambda PowerShell Write-Debug" -Debug)
  • Also set environment variable AWS_LAMBDA_HANDLER_LOG_LEVEL with value DEBUG (refer blog post Introducing the .NET 6 runtime for AWS Lambda). This will enable Debug logs at Lambda level.

Copy link
Contributor

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. module/custom-runtime p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

2 participants