You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "Mauro Molinari (JIRA)" <ji...@apache.org> on 2017/06/26 13:25:00 UTC
[jira] [Created] (LOG4J2-1957) WriterAppender: clarify its usage
Mauro Molinari created LOG4J2-1957:
--------------------------------------
Summary: 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)