diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java index 6b37b15685d7d..6108893f04013 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java @@ -6,6 +6,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -687,6 +688,24 @@ private static Handler configureSyslogHandler(final SyslogConfig config, final E handler.setTruncate(config.truncate); handler.setUseCountingFraming(config.useCountingFraming); handler.setLevel(config.level); + if (config.maxLength.isPresent()) { + BigInteger maxLen = config.maxLength.get().asBigInteger(); + if (maxLen.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) > 0) { + errorManager.error( + "Using 2GB as the value of maxLength for SyslogHandler as it is the maximum allowed value", null, + ErrorManager.GENERIC_FAILURE); + maxLen = BigInteger.valueOf(Integer.MAX_VALUE); + } else { + BigInteger minimumAllowedMaxLength = BigInteger.valueOf(128); + if (maxLen.compareTo(minimumAllowedMaxLength) < 0) { + errorManager.error( + "Using 128 as the value of maxLength for SyslogHandler as using a smaller value is not allowed", + null, ErrorManager.GENERIC_FAILURE); + maxLen = minimumAllowedMaxLength; + } + } + handler.setMaxLength(maxLen.intValue()); + } Formatter formatter = null; boolean formatterWarning = false; diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/SyslogConfig.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/SyslogConfig.java index 0411d345fdcc3..767a0a5b92c85 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/logging/SyslogConfig.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/SyslogConfig.java @@ -10,6 +10,7 @@ import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.configuration.MemorySize; @ConfigGroup public class SyslogConfig { @@ -95,6 +96,15 @@ public class SyslogConfig { @ConfigItem Optional filter; + /** + * The maximum length, in bytes, of the message allowed to be sent. The length includes the header and the message. + *

+ * If not set, the default value is {@code 2048} when {@code sys-log-type} is {@code rfc5424} (which is the default) + * and {@code 1024} when {@code sys-log-type} is {@code rfc3164} + */ + @ConfigItem + Optional maxLength; + /** * Syslog async logging config */