[
https://issues.apache.org/jira/browse/LOG4J2-2977?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17256058#comment-17256058
]
Ron Grabowski commented on LOG4J2-2977:
---------------------------------------
As a first timer looking at log4j's Plugin/Builder pattern I got confused on
two things:
# _set_ vs _with_: what's the difference, why not choose one for consistency?
# Documentation on default values without having to look at implementation
{code}
// release-2.x
Appender appender = FileAppender.newBuilder()
.withFileName("target/test.log")
.withAppend(true)
.withLocking(true)
.setName("File")
.withImmediateFlush(true)
.setIgnoreExceptions(false)
.withBufferedIo(false)
.withBufferSize(4000)
.setLayout(layout)
.setFilter(null)
.withAdvertise(false)
.withAdvertiseUri(null)
.setConfiguration(config).build();
{code}
I had to look at the implementation to realize I could omit several settings
and accept default values:
{code}
// release-2.x
Appender appender = FileAppender.newBuilder()
.withFileName("target/test.log")
// .withAppend(true)
.withLocking(true)
.setName("File")
.withImmediateFlush(true)
// .setIgnoreExceptions(false)
.withBufferedIo(false)
.withBufferSize(4000)
.setLayout(layout)
// .setFilter(null)
// .withAdvertise(false)
// .withAdvertiseUri(null)
.setConfiguration(config).build();
{code}
Doesn't look like our Builder classes are fully auto-generated with IntelliJ so
its seems safe to invest time on Javadoc to document special default values?
I understand there may some nuisances in Plugin/Builder between release-2.x and
master.
> Documentation for code to create a FileAppender is out of date
> --------------------------------------------------------------
>
> Key: LOG4J2-2977
> URL: https://issues.apache.org/jira/browse/LOG4J2-2977
> Project: Log4j 2
> Issue Type: Improvement
> Components: Configuration
> Affects Versions: 2.13.3
> Environment: Please update the documentation with code that
> successfully can create a FileAppender
> Reporter: Bryan Pauquette
> Assignee: Ron Grabowski
> Priority: Minor
> Attachments: image-2020-12-14-09-23-04-411.png
>
>
> [http://logging.apache.org/log4j/2.x/manual/customconfig.html#AddingToCurrent]
>
> Appears to be out of date because the createLayout method is no longer
> available.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)