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

Filipp Gunbin commented on LOG4J2-2636:
---------------------------------------

[~rgoers]
1) AFAICT, if we provide xml config for layout, mdcId will get default value. 
If we provide xml config for SyslogAppender, yes it will pass the value to 
layout, but without default. This is what I meant. I think it would be 
consistent to provide same default no matter how the component is created via 
xml config. I may be missing something, tho.
3) Thanks.

> No default value for mdcId in SyslogAppender
> --------------------------------------------
>
>                 Key: LOG4J2-2636
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2636
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.11.2
>            Reporter: Filipp Gunbin
>            Priority: Major
>             Fix For: 2.12.0
>
>
> 1) Main issue
> When Rfc5424Layout is created from configuration, it seems to receive default 
> value:
> {code:java}
> @PluginAttribute(value = "mdcId", defaultString = DEFAULT_MDCID) final String 
> mdcId,{code}
> But SyslogAppender has it with no default:
> {code:java}
> @PluginBuilderAttribute("mdcId")
> private String mdcId;{code}
> 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:
> {quote}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)
> {quote}
> 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:
> {code:java}
> this.mdcId = id == null ? DEFAULT_MDCID : id;         
> this.mdcSdId = new StructuredDataId(mdcId, enterpriseNumber, null, 
> null);{code}
> 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.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to