From 66a2455035e69cb4b1769a7cdec0731dbac21e06 Mon Sep 17 00:00:00 2001 From: sndyuk Date: Sat, 3 Oct 2020 23:39:14 +0900 Subject: [PATCH] Add bufferChunkRetentionTimeMillis option for fluency #53 --- README.md | 1 + pom-JAVA9MODULE_SLF4J17.xml | 32 +++++++++---------- pom.xml | 10 ++---- .../more/appenders/DataFluentAppender.java | 11 ++++--- .../appenders/FluencyLogbackAppender.java | 10 ++++++ .../resources/logback-appenders-fluentd.xml | 1 + 6 files changed, 36 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 27eb13e..40e5d16 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Just add it to your dependency then you can use the slf4j module in your applica * Add options for Fluent / Fluency appenders: * "encoder" option becomes optional. If you don't set encoder, the log message outputs pure message. * "messageFieldKeyName" option has been added: Set it if you want to change the default message field key name(= "message"). +* Add options for Fluency appender: `bufferChunkRetentionTimeMillis` * Fix bug: Messages were lost sometimes when the messages had been waiting for flushing on shutting down an application. * Fix bug: Fluent appender: Do not raise an error when a fluentd server is down. diff --git a/pom-JAVA9MODULE_SLF4J17.xml b/pom-JAVA9MODULE_SLF4J17.xml index e096bf6..ac5c7d5 100644 --- a/pom-JAVA9MODULE_SLF4J17.xml +++ b/pom-JAVA9MODULE_SLF4J17.xml @@ -2,7 +2,7 @@ 4.0.0 com.sndyuk logback-more-appenders - 1.8.0-JAVA9MODULE_SLF4J17 + 1.8.1-JAVA9MODULE_SLF4J17 logback-more-appenders logback appenders. https://github.com/sndyuk/logback-more-appenders @@ -53,31 +53,31 @@ - org.apache.maven.plugins - maven-compiler-plugin - 3.7.0 + org.codehaus.mojo + build-helper-maven-plugin + 3.2.0 - default-compile - - 9 - - - - base-compile + add-source + generate-sources - compile + add-source - - module-info.java - + + src/java9/java + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 true - 8 + 9 ${project.build.sourceEncoding} ${jdk.version} ${jdk.version} diff --git a/pom.xml b/pom.xml index 3f71d56..5c2c474 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.sndyuk logback-more-appenders - 1.8.0 + 1.8.1 logback-more-appenders logback appenders. https://github.com/sndyuk/logback-more-appenders @@ -21,7 +21,7 @@ 1.2.3 2.9.8 1.11.642 - 1.7 + 7 utf-8 @@ -58,9 +58,6 @@ ${project.build.sourceEncoding} ${jdk.version} ${jdk.version} - - **/module-info.java - @@ -91,9 +88,6 @@ ${jdk.version} -Xdoclint:none - - **/module-info.java - diff --git a/src/main/java/ch/qos/logback/more/appenders/DataFluentAppender.java b/src/main/java/ch/qos/logback/more/appenders/DataFluentAppender.java index 6fa03b8..8499151 100644 --- a/src/main/java/ch/qos/logback/more/appenders/DataFluentAppender.java +++ b/src/main/java/ch/qos/logback/more/appenders/DataFluentAppender.java @@ -13,14 +13,15 @@ */ package ch.qos.logback.more.appenders; -import static ch.qos.logback.core.CoreConstants.CODES_URL; -import java.util.HashMap; -import java.util.Map; -import org.fluentd.logger.FluentLogger; import ch.qos.logback.core.Layout; import ch.qos.logback.core.encoder.Encoder; import ch.qos.logback.core.encoder.LayoutWrappingEncoder; -import org.fluentd.logger.sender.ExponentialDelayReconnector; +import org.fluentd.logger.FluentLogger; + +import java.util.HashMap; +import java.util.Map; + +import static ch.qos.logback.core.CoreConstants.CODES_URL; public class DataFluentAppender extends FluentdAppenderBase { private FluentLogger fluentLogger; diff --git a/src/main/java/ch/qos/logback/more/appenders/FluencyLogbackAppender.java b/src/main/java/ch/qos/logback/more/appenders/FluencyLogbackAppender.java index ac09abd..304c8c4 100644 --- a/src/main/java/ch/qos/logback/more/appenders/FluencyLogbackAppender.java +++ b/src/main/java/ch/qos/logback/more/appenders/FluencyLogbackAppender.java @@ -129,6 +129,7 @@ public void stop() { private String fileBackupDir; private Integer bufferChunkInitialSize; private Integer bufferChunkRetentionSize; + private Integer bufferChunkRetentionTimeMillis; private Long maxBufferSize; private Integer connectionTimeoutMilli; private Integer readTimeoutMilli; @@ -207,6 +208,14 @@ public void setBufferChunkRetentionSize(Integer bufferChunkRetentionSize) { this.bufferChunkRetentionSize = bufferChunkRetentionSize; } + public Integer getBufferChunkRetentionTimeMillis() { + return bufferChunkRetentionTimeMillis; + } + + public void setBufferChunkRetentionTimeMillis(Integer bufferChunkRetentionTimeMillis) { + this.bufferChunkRetentionTimeMillis = bufferChunkRetentionTimeMillis; + } + public Long getMaxBufferSize() { return maxBufferSize; } @@ -284,6 +293,7 @@ protected FluencyBuilderForFluentd configureFluency() { if (fileBackupDir != null) { builder.setFileBackupDir(fileBackupDir); } if (bufferChunkInitialSize != null) { builder.setBufferChunkInitialSize(bufferChunkInitialSize); } if (bufferChunkRetentionSize != null) { builder.setBufferChunkRetentionSize(bufferChunkRetentionSize); } + if (bufferChunkRetentionTimeMillis != null) { builder.setBufferChunkRetentionTimeMillis(bufferChunkRetentionTimeMillis); } if (maxBufferSize != null) { builder.setMaxBufferSize(maxBufferSize); } if (connectionTimeoutMilli != null) { builder.setConnectionTimeoutMilli(connectionTimeoutMilli); } if (readTimeoutMilli != null) { builder.setReadTimeoutMilli(readTimeoutMilli); } diff --git a/src/test/resources/logback-appenders-fluentd.xml b/src/test/resources/logback-appenders-fluentd.xml index 27c9ed0..64291d0 100644 --- a/src/test/resources/logback-appenders-fluentd.xml +++ b/src/test/resources/logback-appenders-fluentd.xml @@ -96,6 +96,7 @@ 2097152 16777216 268435456 + 1000 5000 5000 30