Samsung72 commented on code in PR #836:
URL: https://github.com/apache/logging-log4j2/pull/836#discussion_r871121018


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/layout/Rfc5424Layout.java:
##########
@@ -634,11 +640,142 @@ public static Rfc5424Layout createLayout(
             includes = null;
         }
 
-        return new Rfc5424Layout(config, facility, id, enterpriseNumber, 
includeMDC, newLine, escapeNL, mdcId,
+        return new Rfc5424Layout(config, facility, id, 
String.valueOf(enterpriseNumber), includeMDC, newLine, escapeNL, mdcId,
                 mdcPrefix, eventPrefix, appName, msgId, excludes, includes, 
required, StandardCharsets.UTF_8,
                 exceptionPattern, useTlsMessageFormat, loggerFields);
     }
 
+    public static class Rfc5424LayoutBuilder {
+        private Configuration config;
+        private Facility facility;
+        private String id;
+        private String ein;
+        private boolean includeMDC;
+        private boolean includeNL;
+        private String escapeNL;
+        private String mdcId;
+        private String mdcPrefix;
+        private String eventPrefix;
+        private String appName;
+        private String messageId;
+        private String excludes;
+        private String includes;
+        private String required;
+        private Charset charset;
+        private String exceptionPattern;
+        private boolean useTLSMessageFormat;
+        private LoggerFields[] loggerFields;
+
+        public Rfc5424LayoutBuilder setConfig(Configuration config) {
+            this.config = config;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setFacility(Facility facility) {
+            this.facility = facility;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setId(String id) {
+            this.id = id;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setEin(String ein) {
+            this.ein = ein;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setIncludeMDC(boolean includeMDC) {
+            this.includeMDC = includeMDC;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setIncludeNL(boolean includeNL) {
+            this.includeNL = includeNL;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setEscapeNL(String escapeNL) {
+            this.escapeNL = escapeNL;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setMdcId(String mdcId) {
+            this.mdcId = mdcId;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setMdcPrefix(String mdcPrefix) {
+            this.mdcPrefix = mdcPrefix;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setEventPrefix(String eventPrefix) {
+            this.eventPrefix = eventPrefix;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setAppName(String appName) {
+            this.appName = appName;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setMessageId(String messageId) {
+            this.messageId = messageId;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setExcludes(String excludes) {
+            this.excludes = excludes;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setIncludes(String includes) {
+            this.includes = includes;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setRequired(String required) {
+            this.required = required;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setCharset(Charset charset) {
+            this.charset = charset;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setExceptionPattern(String 
exceptionPattern) {
+            this.exceptionPattern = exceptionPattern;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setUseTLSMessageFormat(boolean 
useTLSMessageFormat) {
+            this.useTLSMessageFormat = useTLSMessageFormat;
+            return this;
+        }
+
+        public Rfc5424LayoutBuilder setLoggerFields(LoggerFields[] 
loggerFields) {
+            this.loggerFields = loggerFields;
+            return this;
+        }
+
+        public Rfc5424Layout build() {
+            if (includes != null && excludes != null) {
+                LOGGER.error("mdcIncludes and mdcExcludes are mutually 
exclusive. Includes wil be ignored");
+                includes = null;
+            }
+
+            if (ein != null && !ENTERPRISE_ID_PATTERN.matcher(ein).find()) {

Review Comment:
   > I would use `matches()` instead of `find()`, since the entire enterprise 
id must match the regular expression.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to