diff --git a/lib/logging/logger.js b/lib/logging/logger.js index f4b8cb9..095389f 100644 --- a/lib/logging/logger.js +++ b/lib/logging/logger.js @@ -6,6 +6,16 @@ const logFormat = winston.format.combine( winston.format.json() ); +const cloudwatchTransport = new winston.transports.CloudWatch({ + logGroupName: process.env.CLOUDWATCH_LOG_GROUP, + logStreamName: process.env.CLOUDWATCH_LOG_STREAM, + awsRegion: process.env.AWS_REGION +}); + +cloudwatchTransport.on('error', (err) => { + console.error('CloudWatch Transport Error:', err); +}); + const logger = winston.createLogger({ level: 'debug', format: logFormat, @@ -14,11 +24,7 @@ const logger = winston.createLogger({ new winston.transports.Console({ format: logFormat, }), - new winston.transports.CloudWatch({ - logGroupName: process.env.CLOUDWATCH_LOG_GROUP, - logStreamName: process.env.CLOUDWATCH_LOG_STREAM, - awsRegion: process.env.AWS_REGION, - }) + cloudwatchTransport ], });