Details
-
Bug
-
Status: Reopened
-
Major
-
Resolution: Unresolved
-
2.11.2
-
None
-
None
Description
1) Main issue
When Rfc5424Layout is created from configuration, it seems to receive default value:
@PluginAttribute(value = "mdcId", defaultString = DEFAULT_MDCID) final String mdcId,
But SyslogAppender has it with no default:
@PluginBuilderAttribute("mdcId") private String mdcId;
It is used in SyslogAppender.build() to create Rfc5424Layout. So, if I don't specify "mdcId" attribute in <Syslog>" config element, I get this exception:
ERROR StatusLogger Could not create plugin of type class org.apache.logging.log4j.core.appender.SyslogAppender for element Syslog: java.lang.IllegalArgumentException: No structured id name was supplied java.lang.IllegalArgumentException: No structured id name was supplied at org.apache.logging.log4j.message.StructuredDataId.<init>(StructuredDataId.java:146) at org.apache.logging.log4j.message.StructuredDataId.<init>(StructuredDataId.java:130) at org.apache.logging.log4j.core.layout.Rfc5424Layout.<init>(Rfc5424Layout.java:142) at org.apache.logging.log4j.core.layout.Rfc5424Layout.createLayout(Rfc5424Layout.java:672) at org.apache.logging.log4j.core.appender.SyslogAppender$Builder.build(SyslogAppender.java:117) at org.apache.logging.log4j.core.appender.SyslogAppender$Builder.build(SyslogAppender.java:50)
2) Documentation doesn't mention mdcId of SyslogAppender at all: https://logging.apache.org/log4j/2.x/manual/appenders.html#SyslogAppender
If I build site locally with "mvn site" in 2.11.2, it's not there either.
3) Commit ce1183629fe89625a77872c7153853e7774502a6 (https://issues.apache.org/jira/browse/LOG4J2-922) which introduces default value for mdcId in Rfc5424Layout has this code:
this.mdcId = id == null ? DEFAULT_MDCID : id; this.mdcSdId = new StructuredDataId(mdcId, enterpriseNumber, null, null);
While "this.mdcId" is set in first line, the argument (not class member) mdcId is used in the second line. Maybe argument mdcId should be used in the first line instead of "id"? Maybe this.mdcId should be used in the second line instead of argument mdcId? I'm not familiar with the code enough to tell for sure, it just feels suspicious to me.
Thanks.
Attachments
Issue Links
- relates to
-
LOG4J2-922 Parameter of mdcId in SyslogAppender has no default value.
- Resolved