aws-lambdaamazon-cloudwatchamazon-cloudwatchlogs

CloudWatch Lambda logs not showing nested object content


When I try to see the log of the nested object, it shows it as [object] instead of showing the actual object. Before I Console.log the object it looks fine, only show like this in the log itself.

The output looks like this:

 { url: 'https://api.11111.co.il/v1/items/11111',
     method: 'put',
     internal_data:
      { content_type: 'application/x-www-form-urlencoded',
        content_format: 'string' },
     data:
      { token:
         'XXXXXXXXXXXXXXXXXXXXXXXXX',
        item: [Object] } } }

log image


Solution

  • If you are using Node.js, you should log objects as

    console.log(JSON.stringify(objectToPrint));
    

    Other languages also have different mechanisms to convert complex JSON objects to string.