lazywithclass / winston-cloudwatch

Send logs to Amazon Cloudwatch using Winston.
MIT License
258 stars 104 forks source link

How do i log using "@aws-sdk/client-cloudwatch-logs" ? #195

Closed tc closed 2 years ago

tc commented 2 years ago

The README says to use

const AWS = require('aws-sdk');

winston.add(new WinstonCloudWatch({
  cloudWatchLogs: new AWS.CloudWatchLogs(),
  logGroupName: 'testing',
  logStreamName: 'first'
}));

"@aws-sdk/client-cloudwatch-logs" doesn't provide a AWS.CloudWatchLogs()

I tried

new WinstonCloudWatch({
  cloudWatchLogs: new CloudWatchLogsClient(),
  logGroupName: 'web-app',
  logStreamName: `${process.env.NODE_ENV}`,
  retentionInDays: 5
})

But get error: uncaughtException aws.describeLogStreams is not a function aws.describeLogStreams is not a function

tc commented 2 years ago

i see! use CloudWatchLogs not CloudWatchLogsClient