aws-lambda-dotnet icon indicating copy to clipboard operation
aws-lambda-dotnet copied to clipboard

PowerShell Lambda functions should allow logging without a default '[PREFIX]' value

Open austoonz opened this issue 5 years ago • 2 comments

Overview

The current logging implementation for PowerShell Lambda functions (as defined in the PowerShellHost) adds a prefix to all CloudWatch logs depending on the PowerShel stream the log came from. This prevents JSON usage in logs for CloudWatch Logs Metric Filters or for additional downstream services retriving pure JSON log entries.

Perhaps a new standard Environment Variable could be added to prevent this prefix, say DISABLE_LOG_PREFIX?

Current Behavior:

Lambda Code:

$log = ConvertTo-Json -Compress -InputObject @{
    LogType = 'Custom'
    Message = 'This is my log message'
}
Write-Verbose -Message $log -Verbose

CloudWatch Logs: [VERBOSE] {"Message":"This is my log message","LogType":"Custom"}

Desired Behavior:

Environment Variable DISABLE_LOG_PREFIX exists with any non-empty value. Lambda Code:

$log = ConvertTo-Json -Compress -InputObject @{
    LogType = 'Custom'
    Message = 'This is my log message'
}
Write-Verbose -Message $log -Verbose

CloudWatch Logs: {"Message":"This is my log message","LogType":"Custom"}

austoonz avatar Jun 27 '19 22:06 austoonz

Thanks for the feedback. I also like the idea of some more configuration here.

klaytaybai avatar Jul 01 '19 21:07 klaytaybai

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

github-actions[bot] avatar Aug 11 '22 00:08 github-actions[bot]