In this video we are going to learn a lambda function logging in Node.js example it is lambda automatically
monitors lambda functions on behalf and sends the function matrix to the Amazon cloud.
Watch.
A lambda function comes with the cloud watch logs, log groups and the log stream for each instance
or of our invocations.
Lambda Runtime Environment sent details about each invocation to the log stream and relies logs and
other outputs from our function code.
So in this video we will see how to produce log output from our lambda function code and access logs
using the alias CLI and lambda console and see the cloud watch logs.
So let's create an example step for our case.
So in our case, please open the Visual Studio code and see that we will develop Lambda Function Code
to update with the logging information.
Zip function code update function code weekly and invoke updated function code.
So let's start with the first step, which is the Lambda function code.
As you remember that in the last video we have developed this index file to see context object and use
the console log operation.
So in this video, I'm going to update a bit about this function code.
For example, let's remove this log operation.
You can see that this is the standard log operation.
I'm going to use different type of to log into the lambda function.
So I'm going to remove this line of code and test in here.
Okay.
So basically we have some log types we can use console.log for the standard logs and we can use console
info to produce info log.
We can use console that one method for producing warning logs into our cloud watch events for Node.js
Lambda functions.
So please save this file.
And this is the our updated function code and we will follow these log information to the Amazon cloud
logs.
So I have updated our lambda function and follow the steps that we are going to update function.
So basically I'm going to zip function code copy from Windows one and go to lecture five to file and
create a function zip file.
And the third step is update lambda function code with CLI.
So I'm going to use this command which is the update function code giving the function name as my function
tree and specifying the function zip file hit enter.
And this will be update our function code.
You can verify from the management console and the last step is invoke our object, we can create an
object.
So basically I'm copying from previous lecture and paste in here key value.
Okay.
If you follow our command text, we are going to invoke our function bit using this address.
Lambda invoke command and here is my function name and here is the payload paste in here and hit enter.
This will be invoke our lambda function and see the response.
JSON is created successfully.
Now the important thing is we have created three type of logs in here.
So now let's check these logs from the Amazon cloud logs.
For that purpose I'm going to open our application.
So here you can find the lambda functions and open my function tree.
Go to monitor and open veev logs in the cloud watch logs and here we will see the last log stream and
you can see that we have tree log statement in our function.
This tree offline comes with these lines in the cloud logs.
The first one is the console log, standard log, standard log.
That means it is creating info log and the second one is info log.
We are creating an envelope and the last one is one warning log.
You can see warning log is a log type is a one in here.
So as you can see that we have seen a lambda function logging in logs example.