vy commented on code in PR #2853:
URL: https://github.com/apache/logging-log4j2/pull/2853#discussion_r1730834276


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java:
##########
@@ -52,23 +53,35 @@ private NetUtils() {
      * @return String the name of the local host
      */
     public static String getLocalHostname() {
+        return getHostname(InetAddress::getHostName);
+    }
+
+    /**
+     * This method gets the FQDN of the machine we are running on. Returns
+     * "UNKNOWN_LOCALHOST" in the unlikely case where the host name cannot be 
found.
+     *
+     * @return String the canonical name of the local host

Review Comment:
   ```suggestion
        * This method gets the FQDN of the machine we are running on.
        * It returns {@value UNKNOWN_LOCALHOST} if the host name cannot be 
found.
        *
        * @return The canonical name of the local host; or {@value 
UNKNOWN_LOCALHOST}, if cannot be found.
   ```



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/layout/Rfc5424Layout.java:
##########
@@ -642,80 +642,128 @@ public String toString() {
      * @return An Rfc5424Layout.
      * @deprecated Use {@link Rfc5424LayoutBuilder instead}
      */
-    @PluginFactory
+    @Deprecated
     public static Rfc5424Layout createLayout(
-            // @formatter:off
-            @PluginAttribute(value = "facility", defaultString = "LOCAL0") 
final Facility facility,
-            @PluginAttribute("id") final String id,
-            @PluginAttribute(value = "enterpriseNumber", defaultInt = 
DEFAULT_ENTERPRISE_NUMBER)
-                    final int enterpriseNumber,
-            @PluginAttribute(value = "includeMDC", defaultBoolean = true) 
final boolean includeMDC,
-            @PluginAttribute(value = "mdcId", defaultString = DEFAULT_MDCID) 
final String mdcId,
-            @PluginAttribute("mdcPrefix") final String mdcPrefix,
-            @PluginAttribute("eventPrefix") final String eventPrefix,
-            @PluginAttribute(value = "newLine") final boolean newLine,
-            @PluginAttribute("newLineEscape") final String escapeNL,
-            @PluginAttribute("appName") final String appName,
-            @PluginAttribute("messageId") final String msgId,
-            @PluginAttribute("mdcExcludes") final String excludes,
-            @PluginAttribute("mdcIncludes") String includes,
-            @PluginAttribute("mdcRequired") final String required,
-            @PluginAttribute("exceptionPattern") final String exceptionPattern,
-            // RFC 5425
-            @PluginAttribute(value = "useTlsMessageFormat") final boolean 
useTlsMessageFormat,
-            @PluginElement("LoggerFields") final LoggerFields[] loggerFields,
-            @PluginConfiguration final Configuration config) {
-        // @formatter:on
+            final Facility facility,
+            final String id,
+            final int enterpriseNumber,
+            final boolean includeMDC,
+            final String mdcId,
+            final String mdcPrefix,
+            final String eventPrefix,
+            final boolean newLine,
+            final String escapeNL,
+            final String appName,
+            final String msgId,
+            final String excludes,
+            String includes,
+            final String required,
+            final String exceptionPattern,
+            final boolean useTlsMessageFormat,
+            final LoggerFields[] loggerFields,
+            final Configuration config) {
         if (includes != null && excludes != null) {
             LOGGER.error("mdcIncludes and mdcExcludes are mutually exclusive. 
Includes wil be ignored");
             includes = null;
         }
 
-        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;
+        return newBuilder()
+                .setConfiguration(config)
+                .setFacility(facility)
+                .setId(id)
+                .setEin(String.valueOf(enterpriseNumber))
+                .setIncludeMDC(includeMDC)
+                .setIncludeNL(newLine)
+                .setEscapeNL(escapeNL)
+                .setMdcId(mdcId)
+                .setMdcPrefix(mdcPrefix)
+                .setEventPrefix(eventPrefix)
+                .setAppName(appName)
+                .setMessageId(msgId)
+                .setExcludes(excludes)
+                .setIncludes(includes)
+                .setRequired(required)
+                .setCharset(StandardCharsets.UTF_8)
+                .setExceptionPattern(exceptionPattern)
+                .setUseTLSMessageFormat(useTlsMessageFormat)
+                .setLoggerFields(loggerFields)
+                .build();
+    }
+
+    @PluginBuilderFactory
+    public static Rfc5424LayoutBuilder newBuilder() {
+        return new Rfc5424LayoutBuilder();
+    }
+
+    public static class Rfc5424LayoutBuilder extends 
AbstractStringLayout.Builder<Rfc5424LayoutBuilder>
+            implements 
org.apache.logging.log4j.core.util.Builder<Rfc5424Layout> {
+
+        @PluginBuilderAttribute
         private Facility facility = Facility.LOCAL0;
+
+        @PluginBuilderAttribute
         private String id;
+
+        @PluginBuilderAttribute
         private String ein = String.valueOf(DEFAULT_ENTERPRISE_NUMBER);
+
+        @PluginBuilderAttribute
+        private Integer enterpriseNumber;
+
+        @PluginBuilderAttribute
         private boolean includeMDC = true;
+
+        @PluginBuilderAttribute
         private boolean includeNL;
+
+        @PluginBuilderAttribute
         private String escapeNL;
+
+        @PluginBuilderAttribute
         private String mdcId = DEFAULT_MDCID;
+
+        @PluginBuilderAttribute
         private String mdcPrefix;
+
+        @PluginBuilderAttribute
         private String eventPrefix;
+
+        @PluginBuilderAttribute
         private String appName;
+
+        @PluginBuilderAttribute
         private String messageId;
+
+        @PluginBuilderAttribute
         private String excludes;
+
+        @PluginBuilderAttribute
         private String includes;
+
+        @PluginBuilderAttribute
         private String required;
-        private Charset charset;
+
+        @PluginBuilderAttribute
         private String exceptionPattern;
+
+        @PluginBuilderAttribute
         private boolean useTLSMessageFormat;
+
+        /**
+         * If {@code true}, the FQDN of the current host will be used.
+         */
+        @PluginBuilderAttribute
+        private boolean useFqdn = false;

Review Comment:
   Given that enabling this fixes our RFC5424 compliance, shouldn't this 
feature be a default instead of opt-in? I am aware that this will be a breaking 
change, yet, I'd favor an approach as follows:
   
   1. Change the default
   2. If we receive a bug report, introduce the flag as an opt-out (contrary to 
the current opt-in)



-- 
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