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

Logger doesn't write to stdout/stderr by default resulting invalid JSON log entries in CloudWatch #241

Open
klindklind opened this issue Dec 3, 2020 · 0 comments

Comments

@klindklind
Copy link

klindklind commented Dec 3, 2020

This is a Bug Report

Description

We switched from Winston to use your logger because it has many features we need out of the box. But then we realized that the loggings are not pure JSON anymore.

  • What went wrong?
    Logs ingested into CloudWatch from our lambda which uses power-logger are not pure JSON. There is a row of plaintext metadata at the beginning of each log entry.

Implementation:

import log from '@dazn/lambda-powertools-logger'

log.info('foo', { bar: 'jar' })

will result in CloudWatch log like:

2020-12-03T09:59:57.754Z	4220ab3e-0559-4a5f-a318-d7b33be19925	INFO	
{
    "message": "foo",
    "data": {
        "bar": "jar"
    },
    "awsRegion": "eu-west-1",
    "functionName": "my-function",
    "functionVersion": "$LATEST",
    "functionMemorySize": "192",
     ... etc. metadata
}
  • What did you expect should have happened?
    Only JSON
{
    "message": "foo",
    "data": {
        "bar": "jar"
    },
    "awsRegion": "eu-west-1",
    "functionName": "my-function",
    "functionVersion": "$LATEST",
    "functionMemorySize": "192",
     ... etc. metadata
}

should've been logged into CloudWatch.

  • Workaround
    We forked the lambda-powertools-logger to explicitly log into process.stdout/.stderr. Could probably open a PR if your intention is to log pure JSON?

Additional Data

  • Which powertool package are you using?: lambda-powertools-logger
  • Which version are you using?: lambda-powertools-logger: 1.24.1
  • Middy engine version you're using: 1.4.0
  • Operating System: Lambda runtime Node 12.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant