0

I have a cloudwatch log group named myTestLogGroup that has a log stream named myTestLogStream.

I also have a lambda named myTestLambda with the following code:

exports.handler = async () => {
    console.log('Hello World!');
    return 200;
}

I would like to see the "Hello World" within the specified myTestLogGroup instead of the default lambda cloudwatch log group.

How can I achieve this? Any SAM templates?

Igor L.
  • 3,159
  • 7
  • 40
  • 61
  • Possible duplicate of [Specify log group for an AWS lambda?](https://stackoverflow.com/questions/39231592/specify-log-group-for-an-aws-lambda) – Deiv Apr 11 '19 at 14:56
  • Note, one of the answers there (other than the selected one) specifies doing so through a CloudFormation template for a specific Lambda log group, which could help you out – Deiv Apr 11 '19 at 14:57

1 Answers1

0

This is currently not possible using console.log statements.

The log group will always be named /aws/lambda/<function name> where you will find log streams per container executions (see https://docs.aws.amazon.com/lambda/latest/dg/monitoring-functions-logs.html).

By using a custom logging solution you could be able to make API calls to CloudWatch Logs to log in your group/stream using a combination of CreateLogGroup, CreateLogStream and PutLogEvents. This seems like a really complicated solution which brings no real added value.

jogold
  • 6,667
  • 23
  • 41