Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pennix/logback-cloudwatch-appender

Logback appender for aws cloudwatch logs using java 11 java.net.http
https://github.com/pennix/logback-cloudwatch-appender

Last synced: 11 days ago
JSON representation

Logback appender for aws cloudwatch logs using java 11 java.net.http

Awesome Lists containing this project

README

        

Logback appender for AWS CloudWatch logs
=========================================

# Background

This package provides a logback appender that writes log events to Cloudwatch logs.
There're many projects out there but I created this because I don't want to include aws sdk and that lots of dependencies just for logging.

* That said, the only dependency of this project is **JSR 374** json processing
* but it is using **java.net.http** to do http request, so you need at least java 11.

# Maven Configuration

``` xml


net.pennix
logback-cloudwatch-appender

1.0.3
runtime

```

## Dependencies

The only dependency besides logback is **JSR 374** json processing, you don't have to include this manually.

``` xml

org.glassfish
javax.json
${javax.jsonp.version}
runtime

```

# logback.xml Configuration

Minimal logback appender configuration:

**NOTE: DO NOT use the same log stream in multiple appenders or multiple application instances, this is a limit by aws**

``` xml


1024


1000


false


${your.aws.access.key.id}
${your.aws.secret.access.key}
${target.region.of.cloudwatch.service}
${your.log.group.name}
${your.log.stream.name}


500


3000


%1.-1level [%thread] %logger - %msg%n

```

See the example [logback-test.xml file](src/main/resources/logback-test.xml).

# IAM Permissions

``` json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:DescribeLogStreams",
"logs:PutLogEvents"
],
"Resource": [
"*"
]
}
]
}
```

You should probably limit **Resource** to specific region/account/logGroup.

# ChangeLog Release Notes

## v1.0.3

* auto correct *nextToken* on *InvalidSequenceTokenException*

## v1.0.2

* add config **httpTimeout**
* catch **Throwable** to prevent worker thread exiting unexpectedly

## v1.0.1

* allow to enable/disable **prepareForDeferredProcessing**
* sleep between puts to reduce cpu usage
* removed some *addInfo* to improve performance