lazywithclass / winston-cloudwatch

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

CloudWatch Logs not getting created #224

Open riyajn17 opened 6 months ago

riyajn17 commented 6 months ago

Hi, I am not able to see logs in my cloudwatch log group when I do any activity in application, It's just I got some logs when I deployed the changes for first time.

This is my logger file - import { createLogger, format } from 'winston'; import WinstonCloudWatch from 'winston-cloudwatch'; import uuid from 'uuid'; import moment from 'moment-timezone';

function messageFormatter({ timestamp, level, message }): string { const logObject: LogObject = { level: level.toUpperCase(), timestamp, message };

return JSON.stringify(logObject); // Convert the object to a JSON string

}

export const logger = createLogger({ exitOnError: false, format: format.combine(format.timestamp(), format.printf(messageFormatter)), transports: [ new WinstonCloudWatch({ logGroupName: 'AmazonDefine-Frontend-Logs', logStreamName: define-frontend-logs-${moment.utc().format('YYYY-MM-DD')}-${uuid.v4()}, awsRegion: 'us-west-2', messageFormatter }) ] });

interface LogObject { level: string; timestamp: string; message: string; }

riyajn17 commented 6 months ago

@lazywithclass , can you please take a look. Thanks