{"id":26679923,"url":"https://github.com/xseman/log4js-appender-cloudwatch","last_synced_at":"2025-04-12T11:33:25.320Z","repository":{"id":216152344,"uuid":"740604005","full_name":"xseman/log4js-appender-cloudwatch","owner":"xseman","description":"Log4js AWS Cloudwatch appender","archived":false,"fork":false,"pushed_at":"2024-12-22T11:47:04.000Z","size":200,"stargazers_count":5,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T06:18:51.993Z","etag":null,"topics":["appender","awscloudwatch","cloudwatch","cloudwatch-logs","log4js","log4js-node"],"latest_commit_sha":null,"homepage":"http://npm.im/log4js-appender-cloudwatch","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xseman.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-08T17:23:27.000Z","updated_at":"2024-12-23T11:04:53.000Z","dependencies_parsed_at":"2024-01-08T18:30:50.292Z","dependency_job_id":"6ecffa07-c155-4e40-ac89-4100ec420f1c","html_url":"https://github.com/xseman/log4js-appender-cloudwatch","commit_stats":null,"previous_names":["xseman/log4js-appender-cloudwatch","arch-group/log4js-appender-cloudwatch"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xseman%2Flog4js-appender-cloudwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xseman%2Flog4js-appender-cloudwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xseman%2Flog4js-appender-cloudwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xseman%2Flog4js-appender-cloudwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xseman","download_url":"https://codeload.github.com/xseman/log4js-appender-cloudwatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248560246,"owners_count":21124616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appender","awscloudwatch","cloudwatch","cloudwatch-logs","log4js","log4js-node"],"created_at":"2025-03-26T06:18:56.799Z","updated_at":"2025-04-12T11:33:25.289Z","avatar_url":"https://github.com/xseman.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# log4js appender - AWS CloudWatch\n\nThis module provides a custom appender for [log4js][log4js_github] that\nsends logs to AWS [CloudWatch][aws_cloudwatch] using the AWS [v3 SDK][cloudwatch_sdk].\n\n[aws_cloudwatch]: https://aws.amazon.com/cloudwatch/\n[cloudwatch_sdk]: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudwatch-logs/\n[log4js_github]: https://log4js-node.github.io/log4js-node/\n\n## Features\n\n- **Batching**: Send multiple log events in a single request to CloudWatch\n- **Buffering**: Send logs after a specified timeout, regardless of the batch size\n- **Log Group and Stream Creation**: Automatically create log groups and streams\n\n## Overview\n\n\u003cimg src=\"docs/sequence.svg\" alt=\"sequence\" width=\"700px\"\u003e\n\n## Installation\n\n### npm registry\n\n```sh\nnpm install log4js-appender-cloudwatch\n```\n\n## Configuration\n\n### Roles\n\n**Required**\n\n```plain\nlogs:PutLogEvents\n```\n\n**To enable the appender to create a group and log stream in AWS, adition roleare\nrequired.**\n\n```plain\nlogs:PutLogEvents\nlogs:CreateLogGroup\nlogs:CreateLogStream\nlogs:DescribeLogStreams\nlogs:DescribeLogGroups\n```\n\n**Reqired for testing.**\n\nTo run tests, create `.env` with AWS access and secret keys.\n\n```plain\nlogs:PutLogEvents\nlogs:GetLogEvents\n```\n\n```json\n{\n\t\"Version\": \"2012-10-17\",\n\t\"Statement\": [\n\t\t{\n\t\t\t\"Action\": [\n\t\t\t\t\"logs:PutLogEvents\",\n\t\t\t\t\"logs:GetLogEvents\"\n\t\t\t],\n\t\t\t\"Effect\": \"Allow\",\n\t\t\t\"Resource\": \"*\"\n\t\t}\n\t]\n}\n```\n\n### TypeScript\n\nIf you're using TypeScript, importing this library as a side effect will\nautomatically merge the log4js interface `Appenders`. This merging enables\nautocomplete for the appenders configuration, providing convenient access to its\nproperties.\n\n```ts\nimport \"log4js-appender-cloudwatch\";\n```\n\n### Example\n\n```ts\nimport log4js from \"log4js\";\n\nimport \"log4js-appender-cloudwatch\";\n\nlog4js.configure({\n\tappenders: {\n\t\tcloudwatch: {\n\t\t\ttype: \"log4js-appender-cloudwatch\",\n\t\t\taccessKeyId: \"\u003csecret\u003e\",\n\t\t\tsecretAccessKey: \"\u003csecret\u003e\",\n\t\t\tregion: \"\u003cconfig\u003e\",\n\t\t\tlogGroupName: \"\u003cconfig\u003e\",\n\t\t\tlogStreamName: \"\u003cconfig\u003e\",\n\t\t\tbatchSize: 10,\n\t\t\tbufferTimeout: 1000, // in ms\n\t\t},\n\t},\n\tcategories: {\n\t\tdefault: {\n\t\t\tlevel: \"debug\",\n\t\t\tappenders: [\n\t\t\t\t\"cloudwatch\",\n\t\t\t],\n\t\t},\n\t},\n});\n\nconst log = log4js.getLogger();\n// ...\n```\n\n## Options\n\n### type\n\n_Required_\\\nType: `log4js-appender-cloudwatch`\n\nType of appender that's loaded from `node_modules`.\n\n### batchSize\n\n_Required_\\\nType: `number`\n\nMaximum number of log events to include in a single batch when sending. Once the\nbatch size is reached, it will be sent to CloudWatch.\n\n### bufferTimeout\n\n_Required_\\\nType: `number`\n\nMaximum time (in milliseconds) to wait before sending a batch of logs,\nregardless of the batch size. If the timeout is reached before the batch size is\nmet, the logs will be sent.\n\n### logGroupName (aws)\n\n_Required_\\\nType: `string`\n\nThe name of the log group in AWS CloudWatch Logs where your logs are stored.\n\n### logStreamName (aws)\n\n_Required_\\\nType: `string`\n\nThe name of the log stream within the specified log group where your logs are\nstored.\n\n### region (aws)\n\n_Required_\\\nType: `string`\n\nThe AWS region where your log group and log stream are located.\n\n### accessKeyId (aws)\n\n_Required_\\\nType: `string`\n\nYour AWS access key ID for authentication.\n\n### secretAccessKey (aws)\n\n_Required_\\\nType: `string`\n\nYour AWS secret access key for authentication.\n\n### sessionToken (aws)\n\n_Optional_\\\nType: `string`\n\nYour AWS session token for authentication. This is used when you are using temporary security credentials.\n\n## Testing\n\nTo test this library during development, you'll need to provide your AWS\ncredentials. These credentials should be stored securely in a `.env` file\nlocated at the root of your project directory.\n\n```sh\n# .env\nACCESSKEY_ID=\"\u003ckey\u003e\"\nSECRET_ACCESS_KEY=\"\u003ckey\u003e\"\n```\n\nThen, you're ready to run tests:\n\n```sh\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxseman%2Flog4js-appender-cloudwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxseman%2Flog4js-appender-cloudwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxseman%2Flog4js-appender-cloudwatch/lists"}