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

Matt Sicker commented on LOG4J2-653:
------------------------------------

Sure! Check this out from Rfc5424LayoutTest:

{code}
final AbstractStringLayout layout = Rfc5424Layout.createLayout(Facility.LOCAL0, 
"Event", 3692, true, "RequestContext",
    null, null, true, null, "ATM", null, "key1, key2, locale", null, "loginId", 
null, true, null, null);
{code}

Now check out what that would look like using a builder:

{code}
final AbstractStringLayout layout = Rfc5424Layout.custom()
    .withId("Event")
    .withEnterpriseNumber(3692)
    .withMdcId("RequestContext")
    .withNewLine(true)
    .withAppName("ATM")
    .withMdcExcludes("key1, key2, locale") // this could probably be converted 
to a vararg method, too
    .withMdcRequired("loginId")
    .withUseTlsMessageFormat(true)
    .build();
{code}

No default values had to be specified, and now I can understand what the unit 
test is configuring!

> Add plugin builder classes as alternative to factory methods.
> -------------------------------------------------------------
>
>                 Key: LOG4J2-653
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-653
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Matt Sicker
>            Assignee: Matt Sicker
>              Labels: config
>
> It would be useful to have builder-style classes as an alternative to plugin 
> factory methods. This would be useful in two settings:
> # Easier to construct plugins in tests and in the code.
> # Can add annotations to fields for value injection in the PluginBuilder 
> class.
> This could replace the existing factory methods, or it could complement it. 
> This would also make it easier to support programmatic configuration.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to