Skip to content

Commit

Permalink
docs: update example
Browse files Browse the repository at this point in the history
  • Loading branch information
xseman committed Jan 8, 2024
1 parent a8511d4 commit f4107ec
Showing 1 changed file with 36 additions and 29 deletions.
65 changes: 36 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# `AWS CloudWatch` log4js appender
# log4js appender - AWS CloudWatch

This module provides a custom appender for [log4js][log4js_github] that
sends logs to AWS [CloudWatch][aws_cloudwatch] using the AWS [v3 SDK][cloudwatch_sdk].

[aws_cloudwatch]: https://aws.amazon.com/cloudwatch/
[cloudwatch_sdk]: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudwatch-logs/
[log4js_github]: https://log4js-node.github.io/log4js-node/

## Installation

**npm registry**
### npm registry

```sh
npm install log4js-appender-cloudwatch
Expand Down Expand Up @@ -88,31 +92,34 @@ import "log4js-appender-cloudwatch"

### Example

```json
{
"appenders": {
"cloudwatch": {
"type": "log4js-appender-cloudwatch",
"accessKeyId": "<secret>",
"secretAccessKey": "<secret>",
"region": "<config>",
"logGroupName": "<config>",
"logStreamName": "<config>",
"batchSize": 10,
"bufferTimeout": 1000,
}
},
"categories": {
"default": {
"level": "debug",
"appenders": [
"cloudwatch"
]
}
}
}
```ts
import log4js from "log4js";

import "log4js-appender-cloudwatch";

log4js.configure({
appenders: {
cloudwatch: {
type: "log4js-appender-cloudwatch",
accessKeyId: "<secret>",
secretAccessKey: "<secret>",
region: "<config>",
logGroupName: "<config>",
logStreamName: "<config>",
batchSize: 10,
bufferTimeout: 1000, // in ms
}
},
categories: {
default: {
level: "debug",
appenders: [
"cloudwatch"
]
}
}
});

const log = log4js.getLogger();
// ...
```

[aws_cloudwatch]: https://aws.amazon.com/cloudwatch/
[cloudwatch_sdk]: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudwatch-logs/
[log4js_github]: https://log4js-node.github.io/log4js-node/

0 comments on commit f4107ec

Please sign in to comment.