diff --git a/README.md b/README.md index 3857b10..e067bd0 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Just add it to your dependency then you can use the slf4j module in your applica ch.qos.logback logback-classic - 1.7.0-JAVA9MODULE_SLF4J17 + 1.7.1-JAVA9MODULE_SLF4J17 ``` @@ -44,7 +44,7 @@ Just add it to your dependency then you can use the slf4j module in your applica ### Latest changes -##### Version 1.7.0 +##### Version 1.7.1 * Fix multithreading problem on CloudWatch and KinesisStream LogbackAppender. @@ -75,7 +75,7 @@ Configure your pom.xml: com.sndyuk logback-more-appenders - 1.7.0 + 1.7.1 diff --git a/pom-JAVA9MODULE_SLF4J17.xml b/pom-JAVA9MODULE_SLF4J17.xml index 33d6975..17e7252 100644 --- a/pom-JAVA9MODULE_SLF4J17.xml +++ b/pom-JAVA9MODULE_SLF4J17.xml @@ -2,7 +2,7 @@ 4.0.0 com.sndyuk logback-more-appenders - 1.7.0-JAVA9MODULE_SLF4J17 + 1.7.1-JAVA9MODULE_SLF4J17 logback-more-appenders logback appenders. https://github.com/sndyuk/logback-more-appenders diff --git a/pom.xml b/pom.xml index 7568370..84a977e 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.sndyuk logback-more-appenders - 1.7.0 + 1.7.1 logback-more-appenders logback appenders. https://github.com/sndyuk/logback-more-appenders @@ -59,7 +59,7 @@ ${jdk.version} ${jdk.version} - module-info.java + **/module-info.java @@ -90,6 +90,9 @@ -Xdoclint:none + + **/module-info.java + diff --git a/src/main/java/ch/qos/logback/more/appenders/AwsAppender.java b/src/main/java/ch/qos/logback/more/appenders/AwsAppender.java index 3513946..415fdad 100644 --- a/src/main/java/ch/qos/logback/more/appenders/AwsAppender.java +++ b/src/main/java/ch/qos/logback/more/appenders/AwsAppender.java @@ -15,6 +15,7 @@ import ch.qos.logback.core.UnsynchronizedAppenderBase; import com.amazonaws.auth.AWSCredentials; +import com.amazonaws.auth.AWSCredentialsProvider; import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; import com.amazonaws.auth.PropertiesCredentials; import com.amazonaws.auth.profile.ProfileCredentialsProvider; @@ -23,6 +24,7 @@ public abstract class AwsAppender extends UnsynchronizedAppenderBase { protected AwsConfig config; + protected AWSCredentialsProvider credentialsProvider; protected AWSCredentials credentials; @Override @@ -34,9 +36,9 @@ public void start() { this.credentials = new PropertiesCredentials(getClass().getClassLoader() .getResourceAsStream(config.getCredentialFilePath())); } else if (config.getProfile() != null && config.getProfile().length() > 0) { - this.credentials = new ProfileCredentialsProvider(config.getProfile()).getCredentials(); + this.credentialsProvider = new ProfileCredentialsProvider(config.getProfile()); } else { - this.credentials = DefaultAWSCredentialsProviderChain.getInstance().getCredentials(); + this.credentialsProvider = DefaultAWSCredentialsProviderChain.getInstance(); } } catch (Exception e) { addWarn("Could not initialize " + AwsAppender.class.getCanonicalName() diff --git a/src/main/java/ch/qos/logback/more/appenders/CloudWatchLogbackAppender.java b/src/main/java/ch/qos/logback/more/appenders/CloudWatchLogbackAppender.java index b3cd366..193bf4f 100644 --- a/src/main/java/ch/qos/logback/more/appenders/CloudWatchLogbackAppender.java +++ b/src/main/java/ch/qos/logback/more/appenders/CloudWatchLogbackAppender.java @@ -13,19 +13,19 @@ */ package ch.qos.logback.more.appenders; -import java.util.Collections; -import java.util.List; -import java.util.UUID; +import ch.qos.logback.core.encoder.EchoEncoder; +import ch.qos.logback.core.encoder.Encoder; +import ch.qos.logback.more.appenders.IntervalEmitter.EventMapper; +import ch.qos.logback.more.appenders.IntervalEmitter.IntervalAppender; import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.client.builder.AwsClientBuilder; import com.amazonaws.services.logs.AWSLogs; import com.amazonaws.services.logs.AWSLogsClientBuilder; import com.amazonaws.services.logs.model.*; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.encoder.EchoEncoder; -import ch.qos.logback.core.encoder.Encoder; -import ch.qos.logback.more.appenders.IntervalEmitter.EventMapper; -import ch.qos.logback.more.appenders.IntervalEmitter.IntervalAppender; + +import java.util.Collections; +import java.util.List; +import java.util.UUID; /** * Appender for CloudWatch. It appends logs for every emitInterval. @@ -107,10 +107,13 @@ protected void append(E eventObject) { private void ensureLogGroup() { if (this.awsLogs == null) { - this.awsLogs = AWSLogsClientBuilder.standard() - .withCredentials(new AWSStaticCredentialsProvider(credentials)) - .withRegion(config.getRegion()) - .build(); + AWSLogsClientBuilder builder = AWSLogsClientBuilder.standard().withRegion(config.getRegion()); + if (credentials != null) { + builder.withCredentials(new AWSStaticCredentialsProvider(credentials)); + } else if (credentialsProvider != null) { + builder.withCredentials(credentialsProvider); + } + this.awsLogs = builder.build(); } DescribeLogGroupsRequest request = new DescribeLogGroupsRequest().withLogGroupNamePrefix(logGroupName).withLimit(1); DescribeLogGroupsResult result = awsLogs.describeLogGroups(request);