You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Ralph Goers (JIRA)" <ji...@apache.org> on 2016/09/18 18:12:20 UTC

[jira] [Commented] (LOG4J2-1597) Add a ScriptSelector Appender to create an Appender specified by a Script

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

Ralph Goers commented on LOG4J2-1597:
-------------------------------------

I think the appenderRef in the example should be InitAppender. The Appender that is created should have the name specified on the selector so the AppenderRef doesn't have to know which was created

> Add a ScriptSelector Appender to create an Appender specified by a Script
> -------------------------------------------------------------------------
>
>                 Key: LOG4J2-1597
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1597
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: Appenders
>            Reporter: Gary Gregory
>            Assignee: Gary Gregory
>
> The use case is to create an OS-based dynamic configuration file.
> The script determines which appender to use (once), and instantiates that appender (once). There is no need for one appender to delegate to another appender.
> This feature helps you build your configuration dynamically, all from the configuration file, to determine which appenders to configure. This is different from using a RoutingAppender which creates a level of indirection and decides what to do for each log event _at runtime_.
> You can use multiple ScriptSelector Appenders if needed.
> For example:
> {code:xml}
> <Configuration status="WARN" name="RoutingTest">
>   <Appenders>
>     <ScriptSelector name="InitAppender">
>       <Script language="JavaScript"><![CDATA[
>          "OSNameFoo".search("Foo") > -1 ? "List2" : "List1";]]>
>       </Script>
>       <AppenderSet>
>         <List name="List1" />
>         <List name="List2" />
>       </AppenderSet>
>     </ScriptSelector>
>   </Appenders>
>   <Loggers>
>     <Root level="error">
>       <AppenderRef ref="Routing" />
>     </Root>
>   </Loggers>
> </Configuration>
> {code}
> The new plugins are ScriptSelector (an Appender that builds a different ScriptSelector) and AppenderSet, a plugin with deferChildren set to true.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org