kaushik srinivas created LOGGING-201:
----------------------------------------

             Summary: Syslog/Socket @ValidHost discards the appender on DNS 
miss at config load; reconnect never runs (Kubernetes late Service DNS; relates 
to LOG4J2-1047)
                 Key: LOGGING-201
                 URL: https://issues.apache.org/jira/browse/LOGGING-201
             Project: Commons Logging
          Issue Type: Bug
    Affects Versions: 2.0.0
            Reporter: kaushik srinivas


h3. Description

Log4j2 {{SyslogAppender}} (and Socket) validates {{host}} with {{@ValidHost}} → 
{{InetAddress.getByName}} once at plugin build. If the name is syntactically 
fine but not in DNS yet (typical Kubernetes: collector Service created after 
the app JVM starts), configuration fail-closes:
 * {{java.net.UnknownHostException}}
 * {{The hostname is invalid}}
 * {{field 'host' has invalid value '…'}}
 * {{Null object returned for Syslog}}
 * {{Unable to locate appender "SYSLOG"}}

{{{}reconnectionDelayMillis{}}}, {{{}immediateFail{}}}, 
{{{}ignoreExceptions{}}}, and {{AsyncAppender}} do not help: there is no 
appender. {{monitorInterval}} only reloads if the config file mtime changes; it 
does not retry DNS by itself.

This matches LOG4J2-1047 (2015, still Open): _When SyslogAppender can't find 
inetAddress at startup, it will never try to reconnect._ Current 2.x surfaces 
the failure at {{@ValidHost}} (LOG4J2-1755 introduced that constraint; it is 
not a separate product bug).

Ask: do not use live DNS as “is this a valid host.” Reject empty/garbage 
{{{}host{}}}; on {{{}UnknownHostException{}}}, still create the appender and 
resolve on connect/reconnect (same idea as the 1047 patch).
h3. Steps to reproduce
 # Log4j2 config with Syslog {{host}} = a DNS name that does not resolve, 
{{{}protocol=TCP{}}}, optional {{{}reconnectionDelayMillis=5000{}}}.
 # Start the JVM. Confirm the errors above; root logger has no SYSLOG.
 # Publish the DNS name (e.g. create the Kubernetes Service). Do not restart, 
do not change/touch the config file.
 # Keep logging.

h3. Actual

SYSLOG never appears for that process. After DNS works, 
{{InetAddress.getByName}} would succeed, but Log4j2 never calls it again.
h3. Expected

After DNS exists, Syslog connects (or retries) without a process restart or a 
forced config-file reload. A typo in {{host}} can still fail fast.
h3. Environment
 * Log4j2 2.x 
 * Kubernetes: {{host}} = {{*.svc.cluster.local}} not present at JVM start, 
present seconds/minutes later



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to