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

Matt Sicker commented on LOG4J2-1957:
-------------------------------------

A possible suggestion on this could be implemented would be to add a 
TypeConverter for Class or similar which would attempt a no-args default 
constructor.

> WriterAppender: clarify its usage
> ---------------------------------
>
>                 Key: LOG4J2-1957
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1957
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.8.1
>            Reporter: Mauro Molinari
>
> I need to create a custom appender, but I see that a {{WriterAppender}} 
> already exists. It would fit my needs, but I'm hitting some difficulties:
> * the documentation at 
> http://logging.apache.org/log4j/2.x/manual/appenders.html does not mention it
> * if I define in my XML something like this:
> {code:xml}
> <Writer name="writer" target="java.io.StringWriter">
>       <Layout type="PatternLayout" pattern="[%-5p] %d{yyyy/MM/dd HH:mm:ss} - 
> %t - %c - %m%n" />
> </Writer>
> {code}
> no field is injected in the builder that builds the appender (because fields 
> are not annotated) and errors like the following are printed:
> {noformat}
> 2017-06-26 15:01:04,755 main ERROR Writer contains invalid attributes "name", 
> "target"
> 2017-06-26 15:01:05,123 main ERROR appender Writer has no parameter that 
> matches element PatternLayout
> {noformat}
> * {{org.apache.logging.log4j.core.appender.WriterAppender}} is final, so I 
> can't extend it to provide my own appender configurable through XML
> IMHO it would be useful to be able to configure a {{WriterAppender}} through 
> XML by specifying the target as a fully qualified class name of my own 
> {{Writer}} implementation.
> If you however want to keep {{WriterAppender}} as something that cannot be 
> configured via XML, an example in the documentation of how to use it in a 
> typical use case via programmatic configuration would be useful.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to