{"id":22109776,"url":"https://github.com/regevbr/log4js-cloudwatch-appender","last_synced_at":"2026-03-10T00:31:05.982Z","repository":{"id":90537753,"uuid":"110471573","full_name":"regevbr/log4js-cloudwatch-appender","owner":"regevbr","description":"log4js simple appender for writing logs to AWS CloudWatch","archived":false,"fork":false,"pushed_at":"2021-03-19T16:10:25.000Z","size":28,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-10T04:27:01.557Z","etag":null,"topics":["appender","aws","cloud","cloud-watch","cloudwatch","cw","javascript","javascript-library","log","log4js","logs","node","nodejs","npm","npm-module","npm-package","watch"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/regevbr.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-11-12T21:42:02.000Z","updated_at":"2024-02-14T11:11:55.000Z","dependencies_parsed_at":"2023-07-18T13:18:36.732Z","dependency_job_id":null,"html_url":"https://github.com/regevbr/log4js-cloudwatch-appender","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/regevbr/log4js-cloudwatch-appender","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regevbr%2Flog4js-cloudwatch-appender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regevbr%2Flog4js-cloudwatch-appender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regevbr%2Flog4js-cloudwatch-appender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regevbr%2Flog4js-cloudwatch-appender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/regevbr","download_url":"https://codeload.github.com/regevbr/log4js-cloudwatch-appender/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regevbr%2Flog4js-cloudwatch-appender/sbom","scorecard":{"id":768824,"data":{"date":"2025-08-11","repo":{"name":"github.com/regevbr/log4js-cloudwatch-appender","commit":"afb29eba81a06605d70e4f06003fc106cc84728f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.5,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 1/21 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU General Public License v3.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T01:39:30.732Z","repository_id":90537753,"created_at":"2025-08-23T01:39:30.732Z","updated_at":"2025-08-23T01:39:30.732Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30318374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","aws","cloud","cloud-watch","cloudwatch","cw","javascript","javascript-library","log","log4js","logs","node","nodejs","npm","npm-module","npm-package","watch"],"created_at":"2024-12-01T09:39:39.858Z","updated_at":"2026-03-10T00:31:05.961Z","avatar_url":"https://github.com/regevbr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/regevbr/log4js-cloudwatch-appender.svg?branch=master)](https://travis-ci.org/regevbr/log4js-cloudwatch-appender)\n[![Coverage Status](https://coveralls.io/repos/github/regevbr/log4js-cloudwatch-appender/badge.svg?branch=master)](https://coveralls.io/github/regevbr/log4js-cloudwatch-appender?branch=master)\n[![bitHound Overall Score](https://www.bithound.io/github/regevbr/log4js-cloudwatch-appender/badges/score.svg)](https://www.bithound.io/github/regevbr/log4js-cloudwatch-appender)\n[![Known Vulnerabilities](https://snyk.io/test/github/regevbr/log4js-cloudwatch-appender/badge.svg)](https://snyk.io/test/github/regevbr/log4js-cloudwatch-appender)\n[![dependencies Status](https://david-dm.org/regevbr/log4js-cloudwatch-appender/status.svg)](https://david-dm.org/regevbr/log4js-cloudwatch-appender)\n[![devDependencies Status](https://david-dm.org/regevbr/log4js-cloudwatch-appender/dev-status.svg)](https://david-dm.org/regevbr/log4js-cloudwatch-appender?type=dev)\n[![npm](https://img.shields.io/npm/dt/log4js-cloudwatch-appender.svg)](https://github.com/regevbr/log4js-cloudwatch-appender)\n[![HitCount](http://hits.dwyl.io/regevbr/log4js-cloudwatch-appender.svg)](http://hits.dwyl.io/regevbr/log4js-cloudwatch-appender)\n\n\n[![https://nodei.co/npm/log4js-cloudwatch-appender.png?downloads=true\u0026downloadRank=true\u0026stars=true](https://nodei.co/npm/log4js-cloudwatch-appender.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://www.npmjs.com/package/log4js-cloudwatch-appender)\n\n# log4js-cloudwatch-appender\nSimple appender for log4js to submit logs to AWS cloudwatch based on the [lawgs](https://github.com/mentum/lawgs) module.\n\n## Installation\n\nThis module is installed via npm:\n\n```\nnpm install --save log4js-cloudwatch-appender\n```\n\n## Usage\n\nAdd aws appender to the log4js config file:\n```js\nconst config = {\n    appenders: {\n        aws: {\n              type: \"log4js-cloudwatch-appender\",\n              accessKeyId: '\u003caccessKeyId\u003e',\n              secretAccessKey: '\u003csecretAccessKey\u003e',\n              region: 'eu-central-1',\n              logGroup: 'prod',\n              logStream: 'apps',\n              layout: '\u003ccustom layout object\u003e',\n              lawgsConfig: '\u003coptional lawgs config object\u003e'\n            }\n    },\n    categories: {\n        default: {appenders: ['aws'], level: 'info'}\n    }\n}\n```\n\nThis will cause logs to be sent to AWS CloudWatch with the specified group and stream.\n\n## Configuration\n\n\nIf you are using roles, you will need the following roles:\n- logs:DescribeLogGroups\n- logs:DescribeLogStreams\n- logs:CreateLogGroup\n- logs:CreateLogStream\n- logs:PutLogEvents\n\n### mandatory\n\n- `region` - The CloudWatch region \n- `logGroup` - The log group to send the metrics to\n- `logStream` - The log stream of the group to send the metrics to\n\n### optional\n\n- `accessKeyId` - Optional if credentials are set in `~/.aws/credentials`\n- `secretAccessKey` - Optional if credentials are set in `~/.aws/credentials`\n- `layout` - Custom layout. See [suggested layout](#suggested-json-layout)\n- `lawgsConfig` - Optional config object for lawgs:\n    - `showDebugLogs` - Show debug logs. Default: false.\n    - `uploadMaxTimer` - After this ms timeout, flush to server. Default: 5000.\n    - `uploadBatchSize` - After this amount of logs, flush to server. Default: 500.\n\n## Suggested json layout\n\nLogs are easier to query when they are formatted as json. \nFollowing is a suggested json layout to set for this appender. \nThe logging style should be:\n\n```js\nconst uuid = require('node-uuid');\nconst corr = uuid.v4();\nconst logger = logFactory.getLogger('category');\n\nlogger.info(corr, 'methodName()','part1','part2');\n```\n\nWhich will output:\n```json\n{\n  \"timestamp\": \"2017-06-10T11:55:38.251Z\",\n  \"corr\": \"2e2c99aa-7eee-4fd2-ae36-cd9dc9533816\",\n  \"app\": \"\u003cappName\u003e\",\n  \"host\": \"\u003cip\u003e\",\n  \"pid\": 24532,\n  \"level\": \"INFO\",\n  \"category\": \"category\",\n  \"method\": \"methodName()\",\n  \"message\": \"part1 part2\"\n}\n```\n\nThe layout:\n\n```js\nconst util = require('util');\nconst _ = require('underscore');\n\nlet processName = path.basename(process.argv[1]);\nprocessName = processName.substring(0, processName.length - 3);\n\nconst publicIp = require('public-ip').v4;\nlet ip = '';\npublicIp()\n  .then(function (_ip) {\n    ip = _ip;\n  })\n  .catch(function (e) {\n    console.log(e);\n    ip = 'unknown';\n  });\n\nconst jsonLayout = {\n  \"type\": \"pattern\",\n  \"pattern\": '{\"timestamp\": \"%d{yyyy-MM-ddThh:mm:ss.SSSZ}\", \"app\": \"' + processName + '\", \"ip\": \"%x{my_ip}\", \"host\": \"%h\", \"pid\": %z, \"level\": \"%p\", \"category\": \"%c\"%x{corr}%x{method}, \"message\": \"%x{message}\"}',\n  \"tokens\": {\n    \"my_ip\": function () {\n      return ip;\n    },\n   \"corr\": function (logEvent) {\n      logEvent.__data__ = _.map(logEvent.data, _.clone);\n      if (logEvent.__data__) {\n        let corr = logEvent.__data__[0];\n        if (Array.isArray(corr) \u0026\u0026 corr.length === 2) {\n          corr = corr[0];\n          if (typeof corr === 'string' \u0026\u0026 corr.length === 36 \u0026\u0026 corr.split(\"-\").length === 5) {\n            logEvent.__data__[0] = logEvent.__data__[0][1];\n            return ', \"corr\": \"' + corr + '\"';\n          }\n        }\n        if (logEvent.__data__.length \u003e 1 \u0026\u0026 corr \u0026\u0026 typeof corr === 'string' \u0026\u0026 corr.length === 36 \u0026\u0026 corr.split(\"-\").length === 5) {\n          logEvent.__data__.shift();\n          return ', \"corr\": \"' + corr + '\"';\n        }\n      }\n      return '';\n    },\n    \"method\": function (logEvent) {\n      if (logEvent.__data__) {\n        const method = logEvent.__data__[0];\n        if (logEvent.__data__.length \u003e 1 \u0026\u0026 method \u0026\u0026 typeof method === 'string' \u0026\u0026 method.indexOf(\"()\", method.length - 2) !== -1) {\n          logEvent.__data__.shift();\n          return ', \"method\": \"' + method + '\"';\n        }\n      }\n      return '';\n    },\n    \"message\": function (logEvent) {\n      if (logEvent.__data__) {\n        let data = logEvent.__data__;\n        data = util.format.apply(util, wrapErrorsWithInspect(data));\n        data = escapedStringify(data);\n        logEvent.__data__ = undefined;\n        return data;\n      }\n      return '';\n    }\n  }\n};\n\nfunction wrapErrorsWithInspect(items) {\n  return items.map(function (item) {\n    if ((item instanceof Error) \u0026\u0026 item.stack) {\n      return {\n        inspect: function () {\n          return util.format(item) + '\\n' + item.stack;\n        }\n      };\n    } else {\n      return item;\n    }\n  });\n}\n\nfunction escapedStringify(json) {\n  return json\n    .replace(/[\\\\]/g, '\\\\\\\\')\n    .replace(/[\\\"]/g, '\\\\\\\"')\n    .replace(/[\\/]/g, '\\\\/')\n    .replace(/[\\b]/g, '\\\\b')\n    .replace(/[\\f]/g, '\\\\f')\n    .replace(/[\\n]/g, '\\\\n')\n    .replace(/[\\r]/g, '\\\\r')\n    .replace(/[\\t]/g, '\\\\t');\n}\n```\n\n## Contributing\n\nPlease make all pull requests to the `master` branch and ensure tests pass\nlocally.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fregevbr%2Flog4js-cloudwatch-appender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fregevbr%2Flog4js-cloudwatch-appender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fregevbr%2Flog4js-cloudwatch-appender/lists"}