You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2017/08/01 23:25:06 UTC

[log4j] Flexible config?

Hi All:

I find it a pain that I cannot say:

    <Logger name="com.example.foo" level="DEBUG">
      <List name="ListAppender">
        <PatternLayout pattern="%m%n" />
      </List>
    </Logger>


Instead I MUST do:

    <Logger name="com.example.foo" level="DEBUG">
      <AppenderRef ref="ListAppender" />
    </Logger>

Any thoughts on allowing the former?

Gary

Re: [log4j] Flexible config?

Posted by Ralph Goers <ra...@dslextreme.com>.
> On Aug 1, 2017, at 4:25 PM, Gary Gregory <ga...@gmail.com> wrote:
> 
> Hi All:
> 
> I find it a pain that I cannot say:
> 
>    <Logger name="com.example.foo" level="DEBUG">
>      <List name="ListAppender">
>        <PatternLayout pattern="%m%n" />
>      </List>
>    </Logger>
> 
> 
> Instead I MUST do:
> 
>    <Logger name="com.example.foo" level="DEBUG">
>      <AppenderRef ref="ListAppender" />
>    </Logger>
> 
> Any thoughts on allowing the former?

Only that you are going to regret doing it.  The instant you want to add a second logger that uses that Appender you will have to revert back to the current syntax. But there really is no reason we cannot create and add an appender where an AppenderRef is required. 

Ralph