Skip to content

Commit

Permalink
Add bufferChunkRetentionTimeMillis option for fluency #53
Browse files Browse the repository at this point in the history
  • Loading branch information
sndyuk committed Oct 3, 2020
1 parent 892ceec commit 66a2455
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 29 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
32 changes: 16 additions & 16 deletions pom-JAVA9MODULE_SLF4J17.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.sndyuk</groupId>
<artifactId>logback-more-appenders</artifactId>
<version>1.8.0-JAVA9MODULE_SLF4J17</version>
<version>1.8.1-JAVA9MODULE_SLF4J17</version>
<name>logback-more-appenders</name>
<description>logback appenders.</description>
<url>https://github.com/sndyuk/logback-more-appenders</url>
Expand Down Expand Up @@ -53,31 +53,31 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<release>9</release>
</configuration>
</execution>
<execution>
<id>base-compile</id>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
<goal>add-source</goal>
</goals>
<configuration>
<excludes>
<exclude>module-info.java</exclude>
</excludes>
<sources>
<source>src/java9/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<fork>true</fork>
<release>8</release>
<release>9</release>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
Expand Down
10 changes: 2 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.sndyuk</groupId>
<artifactId>logback-more-appenders</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
<name>logback-more-appenders</name>
<description>logback appenders.</description>
<url>https://github.com/sndyuk/logback-more-appenders</url>
Expand All @@ -21,7 +21,7 @@
<logback.version>1.2.3</logback.version>
<jackson.version>2.9.8</jackson.version>
<aws.version>1.11.642</aws.version>
<jdk.version>1.7</jdk.version>
<jdk.version>7</jdk.version>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -58,9 +58,6 @@
<encoding>${project.build.sourceEncoding}</encoding>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<excludes>
<exclude>**/module-info.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -91,9 +88,6 @@
<configuration>
<source>${jdk.version}</source>
<additionalparam>-Xdoclint:none</additionalparam>
<sourceFileExcludes>
<sourceFileExclude>**/module-info.java</sourceFileExclude>
</sourceFileExcludes>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<E> extends FluentdAppenderBase<E> {
private FluentLogger fluentLogger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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); }
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/logback-appenders-fluentd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<bufferChunkInitialSize>2097152</bufferChunkInitialSize>
<bufferChunkRetentionSize>16777216</bufferChunkRetentionSize>
<maxBufferSize>268435456</maxBufferSize>
<bufferChunkRetentionTimeMillis>1000</bufferChunkRetentionTimeMillis>
<connectionTimeoutMilli>5000</connectionTimeoutMilli>
<readTimeoutMilli>5000</readTimeoutMilli>
<waitUntilBufferFlushed>30</waitUntilBufferFlushed>
Expand Down

0 comments on commit 66a2455

Please sign in to comment.