You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Filipp Gunbin (JIRA)" <ji...@apache.org> on 2019/07/01 12:13:00 UTC

[jira] [Commented] (LOG4J2-2636) No default value for mdcId in SyslogAppender

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

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

[~rgoers] Yes, I see, but maybe then we don't need default in Rfc5424Layout.java?
{code}
    public static Rfc5424Layout createLayout(
...
    @PluginAttribute(value = "mdcId", defaultString = DEFAULT_MDCID) final String mdcId,
{code}
So the default will always be given explicitly in Rfc5424Layout constructor.

> 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.1
>
>
> 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)