You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "Paul Burrowes (JIRA)" <ji...@apache.org> on 2017/08/04 03:55:00 UTC

[jira] [Commented] (LOG4J2-922) Parameter of mdcId in SyslogAppender has no default value.

    [ https://issues.apache.org/jira/browse/LOG4J2-922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16113905#comment-16113905 ] 

Paul Burrowes commented on LOG4J2-922:
--------------------------------------

This should be reopened and fixed. The commit above, described as fixing the bug, does not touch the faulty line in question.
The DEFAULT_MDCID is only applied when {{createLayout()}} is called via the configuration parser. Creating a SyslogAppender calls this as programmatic configuration and thus fails. The constructor needs to also set the default as is done for {{defaultId}}:
{code}
  private Rfc5424Layout(final Configuration config, final Facility facility, final String id, final int ein,
            final boolean includeMDC, final boolean includeNL, final String escapeNL, final String mdcId,
            final String mdcPrefix, final String eventPrefix, final String appName, final String messageId,
            final String excludes, final String includes, final String required, final Charset charset,
            final String exceptionPattern, final boolean useTLSMessageFormat, final LoggerFields[] loggerFields) {
        super(charset);
        final PatternParser exceptionParser = createPatternParser(config, ThrowablePatternConverter.class);
        exceptionFormatters = exceptionPattern == null ? null : exceptionParser.parse(exceptionPattern);
        this.facility = facility;
        this.defaultId = id == null ? DEFAULT_ID : id;
        this.enterpriseNumber = ein;
        this.includeMdc = includeMDC;
        this.includeNewLine = includeNL;
        this.escapeNewLine = escapeNL == null ? null : Matcher.quoteReplacement(escapeNL);
-        this.mdcId = mdcId;
+        this.mdcId = id == null ? DEFAULT_MDCID : id;
        this.mdcSdId = new StructuredDataId(mdcId, enterpriseNumber, null, null);{code}

> Parameter of mdcId in SyslogAppender has no default value.
> ----------------------------------------------------------
>
>                 Key: LOG4J2-922
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-922
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>            Reporter: angus.aqlu
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> I don't need MDC information, but must setting mdcId.  if not set mdcId, throw a IllegalArgumentException;
> {code:xml|title=Configruation|borderStyle=solid}
> <Syslog name="RFC5424" charset="UTF-8" format="RFC5424" host="192.168.65.181" port="13514" protocol="UDP"
>                 appName="testApp" includeMDC="false" facility="USER"
>                 newline="true" messageId="Audit" "/>
> {code}
> {code:title=exception info}
> Caused by: java.lang.IllegalArgumentException: No structured id name was supplied
> 	at org.apache.logging.log4j.message.StructuredDataId.<init>(StructuredDataId.java:92)
> 	at org.apache.logging.log4j.core.layout.Rfc5424Layout.<init>(Rfc5424Layout.java:139)
> 	at org.apache.logging.log4j.core.layout.Rfc5424Layout.createLayout(Rfc5424Layout.java:657)
> 	at org.apache.logging.log4j.core.appender.SyslogAppender.createAppender(SyslogAppender.java:133)
> 	... 25 more
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)