@nithinta/cloudwatch-logger
v1.0.3
Published
A simple npm package to write logs to AWS CloudWatch using AWS SDK
Downloads
11
Readme
AWS CloudWatch Logger
This is my attempt to write a serialized JSON logs with severity.
Configuration (.env file)
You need to setup log group and and stream in cloudwatch and fill all these in this .env file to start writing logs.
AWS_REGION= AWS_LOG_GROUP_NAME= AWS_LOG_STREAM_NAME= AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY=
Sample script (example.js)
Contains a sample js file to write a log to cloudwatch.
require('dotenv').config(); const CloudWatchLogger = require('./index');
const region = process.env.REGION; const logGroupName = process.env.LOG_GROUP_NAME; const logStreamName = process.env.LOG_STREAM_NAME;
const logger = new CloudWatchLogger(region, logGroupName, logStreamName);
logger.writeLog('Warn', 'This is a test log message')
Retry log writing
This library will reattempt once again when it fails with an sequence token error.