{"_id":"log4js-cloudwatch-appender","_rev":"9-e072c0cd17666b5ed4243dac4bdcc09d","name":"log4js-cloudwatch-appender","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"log4js-cloudwatch-appender","version":"1.0.0","keywords":["aws","cloudwatch","log4js","appender","cloud-watch","cloud","watch","logs","log","cw"],"author":{"name":"regevbr"},"license":"GPL-3.0","_id":"log4js-cloudwatch-appender@1.0.0","maintainers":[{"name":"regevbr","email":"regevbr@gmail.com"}],"homepage":"https://github.com/regevbr/log4js-cloudwatch-appender#readme","bugs":{"url":"https://github.com/regevbr/log4js-cloudwatch-appender/issues"},"dist":{"shasum":"2fc10df0f1342356951ce7e1c5b25cc884a67915","tarball":"https://registry.npmjs.org/log4js-cloudwatch-appender/-/log4js-cloudwatch-appender-1.0.0.tgz","integrity":"sha512-kfwew9fYHkO3RWXMR2w+qV7aFi7HIC2/ol/eL53oAWAE8u1FopKC9MyuZA1zMblWt3ctVaI8XxIRhrDZu18GOg==","signatures":[{"sig":"MEYCIQDbIajNzn8d/giZVdI9lCAFnEGwrOPr4GcJ5aRM05Ew0gIhAK59S8teVKxy0LFsysGK89n2MR0J1r9SzdtayP+4NQ0z","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/index.js","_from":".","_shasum":"2fc10df0f1342356951ce7e1c5b25cc884a67915","gitHead":"37db1f4f4d6688bb7d87ca03456768c24e69666f","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"regevbr","email":"regevbr@gmail.com"},"repository":{"url":"git+https://github.com/regevbr/log4js-cloudwatch-appender.git","type":"git"},"_npmVersion":"3.10.10","description":"log4js aws cloudwatch appender","directories":{},"_nodeVersion":"6.10.1","dependencies":{"lawgs":"^1.0.4"},"_npmOperationalInternal":{"tmp":"tmp/log4js-cloudwatch-appender-1.0.0.tgz_1510524952108_0.6700202042702585","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"log4js-cloudwatch-appender","version":"1.0.1","keywords":["aws","cloudwatch","log4js","appender","cloud-watch","cloud","watch","logs","log","cw"],"author":{"name":"regevbr"},"license":"GPL-3.0","_id":"log4js-cloudwatch-appender@1.0.1","maintainers":[{"name":"regevbr","email":"regevbr@gmail.com"}],"homepage":"https://github.com/regevbr/log4js-cloudwatch-appender#readme","bugs":{"url":"https://github.com/regevbr/log4js-cloudwatch-appender/issues"},"dist":{"shasum":"45fa73814b5978b802861299d15aa42ce513d9d3","tarball":"https://registry.npmjs.org/log4js-cloudwatch-appender/-/log4js-cloudwatch-appender-1.0.1.tgz","integrity":"sha512-HFPC949ZE+ZeNETYL6i6vqqIXyjjYx+hPz3X+oMA3cG98WpR/ZLPnQYGNTL0Y3b5XhVX5Hmnjnv6quSAk5BoaA==","signatures":[{"sig":"MEYCIQD7RpXaDM3WQ5/Tudgxx2PPYAt13R7tgqW3OCPAyby7dgIhAOkYrlw9v4rAHBeEfb0xjf5k5xcgvsHjYWJW5G1PUDHt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/index.js","_from":".","_shasum":"45fa73814b5978b802861299d15aa42ce513d9d3","gitHead":"90a6587d6c7da7ec0f43a3483bdfefc35c7fb5d8","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"regevbr","email":"regevbr@gmail.com"},"repository":{"url":"git+https://github.com/regevbr/log4js-cloudwatch-appender.git","type":"git"},"_npmVersion":"3.10.10","description":"log4js aws cloudwatch appender","directories":{},"_nodeVersion":"6.10.1","dependencies":{"lawgs":"^1.0.4"},"_npmOperationalInternal":{"tmp":"tmp/log4js-cloudwatch-appender-1.0.1.tgz_1510525649017_0.6393126216717064","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"log4js-cloudwatch-appender","version":"1.0.2","keywords":["aws","cloudwatch","log4js","appender","cloud-watch","cloud","watch","logs","log","cw"],"author":{"name":"Regev Brody","email":"regevbr@gmail.com"},"license":"GPL-3.0","_id":"log4js-cloudwatch-appender@1.0.2","maintainers":[{"name":"regevbr","email":"regevbr@gmail.com"}],"homepage":"https://github.com/regevbr/log4js-cloudwatch-appender#readme","bugs":{"url":"https://github.com/regevbr/log4js-cloudwatch-appender/issues"},"dist":{"shasum":"e341442db10d29715f6c1737b074f6d1a591d287","tarball":"https://registry.npmjs.org/log4js-cloudwatch-appender/-/log4js-cloudwatch-appender-1.0.2.tgz","integrity":"sha512-FbJsEjSu6EB4JwahoGSiaCT2+FH1Ag9/NHKGePw/mdV10LQVLAaxletLKfIDWVisR0rKQG8Gx6QdWChuYGGJsg==","signatures":[{"sig":"MEUCIQCqCFMohyj9KihoBvuiMcOt7+xSc0z0swRQhHhghMcnnQIgAzJQLXa/qT39zdLJaLD6cW7HN8NfLUv9/i/Dp35Y0fU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/index.js","_from":".","_shasum":"e341442db10d29715f6c1737b074f6d1a591d287","engines":{"node":">=6.11.3"},"gitHead":"c41f6677097fd4cd30553fc1416ef376fa44ec47","scripts":{"test":"make test"},"_npmUser":{"name":"regevbr","email":"regevbr@gmail.com"},"repository":{"url":"git+https://github.com/regevbr/log4js-cloudwatch-appender.git","type":"git"},"_npmVersion":"3.10.10","description":"log4js aws cloudwatch appender","directories":{},"_nodeVersion":"6.10.1","dependencies":{"lawgs":"^1.0.4"},"devDependencies":{"mocha":"^4.0.1","jshint":"^2.9.5","istanbul":"^0.4.5","coveralls":"^3.0.0","expect.js":"^0.3.1","sandboxed-module":"^2.0.3","mocha-lcov-reporter":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/log4js-cloudwatch-appender-1.0.2.tgz_1510615311356_0.8661921063903719","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"log4js-cloudwatch-appender","version":"1.1.0","keywords":["aws","cloudwatch","log4js","appender","cloud-watch","npm","npm-package","npm-module","javascript-library","cloud","watch","logs","log","cw","node","nodejs","javascript"],"author":{"name":"Regev Brody","email":"regevbr@gmail.com"},"license":"GPL-3.0","_id":"log4js-cloudwatch-appender@1.1.0","maintainers":[{"name":"regevbr","email":"regevbr@gmail.com"}],"homepage":"https://github.com/regevbr/log4js-cloudwatch-appender#readme","bugs":{"url":"https://github.com/regevbr/log4js-cloudwatch-appender/issues"},"dist":{"shasum":"4eaf9039157fe1021def9e4146d23a0f220a4567","tarball":"https://registry.npmjs.org/log4js-cloudwatch-appender/-/log4js-cloudwatch-appender-1.1.0.tgz","integrity":"sha512-cS7PP7gCOLviJg5gmcaAWMk+yaO3C1SDSyYcP8vkBwoGexM+M6AyzT2NQz2G83KF41AdiyFs6MBFZlQU4n55rA==","signatures":[{"sig":"MEYCIQDagUgHEcJG3//pKMqgJpJtKBkyZOGIVzH4taH3uxzDfAIhAIat+S2B3muRWMuGOw7PACGTMWbTzW7EY6Uo38H92AWe","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/index.js","_from":".","_shasum":"4eaf9039157fe1021def9e4146d23a0f220a4567","engines":{"node":">=6.11.3"},"gitHead":"db3830c3b6ba0322023b722a608eb1054f61a5f8","scripts":{"test":"make test"},"_npmUser":{"name":"regevbr","email":"regevbr@gmail.com"},"repository":{"url":"git+https://github.com/regevbr/log4js-cloudwatch-appender.git","type":"git"},"_npmVersion":"3.10.10","description":"log4js aws cloudwatch appender","directories":{},"_nodeVersion":"6.10.1","dependencies":{"lawgs":"^1.0.4"},"devDependencies":{"mocha":"^4.0.1","jshint":"^2.9.5","istanbul":"^0.4.5","coveralls":"^3.0.0","expect.js":"^0.3.1","sandboxed-module":"^2.0.3","mocha-lcov-reporter":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/log4js-cloudwatch-appender-1.1.0.tgz_1512333111303_0.15098517388105392","host":"s3://npm-registry-packages"}},"2.0.0":{"_id":"log4js-cloudwatch-appender@2.0.0","bugs":{"url":"https://github.com/PruvoNet/log4js-cloudwatch-appender/issues"},"dist":{"shasum":"105d3d7a3ef396fbc8c0c8e097fee2c3ae7419b4","tarball":"https://registry.npmjs.org/log4js-cloudwatch-appender/-/log4js-cloudwatch-appender-2.0.0.tgz","fileCount":4,"integrity":"sha512-Qx71xl3aSBRld6KRtEQ3PvkR7+goV6+tGPl+grizuRaWorZZWaoU4gjdXpRyR3rWGVAhKVmpaRbsEfgs+KvkKw==","signatures":[{"sig":"MEUCIHpcS86daYZStgQfh451hf3mZzICYHQFZPX1tA9MhVhMAiEA4dXk0xZU0X/SWcM61E2gXukWWeefWxMOeSgVHNUqQPM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAo4iQsHzhSPQI5c0t21sBDOsyQfL3iMgBEdmQmThYQpAiEA5Ox0Js7zx8hj8U6lvL7uFn2q+3y8qIf8lHzxYYiUmEA="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/log4js-cloudwatch-appender@2.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":43265},"main":"lib/index.js","name":"log4js-cloudwatch-appender","author":{"name":"Regev Brody","email":"regevbr@gmail.com"},"engines":{"node":">=18"},"gitHead":"91e6a962b7f8f3fb66958adf53b30b913159cdc4","license":"GPL-3.0","scripts":{"lint":"jshint ./test ./lib/index.js","test":"npm run lint && NODE_ENV=test mocha -b --reporter spec","cover":"NODE_ENV=test istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec"},"version":"2.0.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"0e52460d-5df3-49fc-b5c6-d7e9aac4538f"}},"homepage":"https://github.com/PruvoNet/log4js-cloudwatch-appender#readme","keywords":["aws","cloudwatch","log4js","appender","cloud-watch","npm","npm-package","npm-module","javascript-library","cloud","watch","logs","log","cw","node","nodejs","javascript"],"repository":{"url":"git+https://github.com/PruvoNet/log4js-cloudwatch-appender.git","type":"git"},"_npmVersion":"11.19.0","description":"log4js aws cloudwatch appender","directories":{},"maintainers":[{"name":"ynahmany-pruvo","email":"yohay.nahmany@pruvo.com"},{"name":"regevbr","email":"regevbr@gmail.com"}],"_nodeVersion":"24.21.0","dependencies":{"lawgs":"^1.0.4"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^4.0.1","jshint":"^2.9.5","istanbul":"^0.4.5","expect.js":"^0.3.1","sandboxed-module":"^2.0.3"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/log4js-cloudwatch-appender_2.0.0_1792403718608_0.3531329014165463"}}},"time":{"created":"2017-11-12T22:15:52.191Z","modified":"2026-10-19T09:55:19.063Z","1.0.0":"2017-11-12T22:15:52.191Z","1.0.1":"2017-11-12T22:27:30.032Z","1.0.2":"2017-11-13T23:21:52.523Z","1.1.0":"2017-12-03T20:31:52.410Z","2.0.0":"2026-10-19T09:55:18.683Z"},"bugs":{"url":"https://github.com/PruvoNet/log4js-cloudwatch-appender/issues"},"author":{"name":"Regev Brody","email":"regevbr@gmail.com"},"license":"GPL-3.0","homepage":"https://github.com/PruvoNet/log4js-cloudwatch-appender#readme","keywords":["aws","cloudwatch","log4js","appender","cloud-watch","npm","npm-package","npm-module","javascript-library","cloud","watch","logs","log","cw","node","nodejs","javascript"],"repository":{"url":"git+https://github.com/PruvoNet/log4js-cloudwatch-appender.git","type":"git"},"description":"log4js aws cloudwatch appender","maintainers":[{"name":"ynahmany-pruvo","email":"yohay.nahmany@pruvo.com"},{"name":"regevbr","email":"regevbr@gmail.com"}],"readme":"[![CI](https://github.com/PruvoNet/log4js-cloudwatch-appender/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/PruvoNet/log4js-cloudwatch-appender/actions/workflows/ci.yml)\n[![npm](https://img.shields.io/npm/v/log4js-cloudwatch-appender.svg)](https://www.npmjs.com/package/log4js-cloudwatch-appender)\n\n[![https://nodei.co/npm/log4js-cloudwatch-appender.png?downloads=true&downloadRank=true&stars=true](https://nodei.co/npm/log4js-cloudwatch-appender.png?downloads=true&downloadRank=true&stars=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: '<accessKeyId>',\n              secretAccessKey: '<secretAccessKey>',\n              region: 'eu-central-1',\n              logGroup: 'prod',\n              logStream: 'apps',\n              layout: '<custom layout object>',\n              lawgsConfig: '<optional lawgs config object>'\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\": \"<appName>\",\n  \"host\": \"<ip>\",\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) && corr.length === 2) {\n          corr = corr[0];\n          if (typeof corr === 'string' && corr.length === 36 && corr.split(\"-\").length === 5) {\n            logEvent.__data__[0] = logEvent.__data__[0][1];\n            return ', \"corr\": \"' + corr + '\"';\n          }\n        }\n        if (logEvent.__data__.length > 1 && corr && typeof corr === 'string' && corr.length === 36 && 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 > 1 && method && typeof method === 'string' && 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) && 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","readmeFilename":"README.md","users":{"bholbrook73":true}}