Matt Sicker created LOG4J2-2600:
-----------------------------------

             Summary: Declarative Groovy Configuration DSL
                 Key: LOG4J2-2600
                 URL: https://issues.apache.org/jira/browse/LOG4J2-2600
             Project: Log4j 2
          Issue Type: New Feature
          Components: Configurators
            Reporter: Matt Sicker


Borrowing the general Groovy syntax used in 
[Stapler|https://github.com/stapler/stapler/tree/master/groovy/src/main/java/org/kohsuke/stapler/jelly/groovy],
 a declarative Groovy syntax comparable to the existing XML/JSON/YAML syntax 
tree for writing configuration files.

For example, a minimal binding implementation might look something like this. 
Starting with an example XML configuration:

{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
  <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - 
%msg%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Logger name="com.foo.Bar" level="trace">
      <AppenderRef ref="Console"/>
    </Logger>
    <Root level="error">
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>
</Configuration>
{code}

This would look like this in the declarative Groovy DSL:

{code:groovy}
configuration(status: 'warn') {
  appenders {
    console(name: 'Console', target: 'SYSTEM_OUT') {
      patternLayout(pattern: '%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - 
%msg%n')
    }
  }
  loggers {
    logger(name: 'com.foo.Bar', level: 'trace') {
      appenderRef(ref: 'Console')
    }
    root(level: 'error') {
      appenderRef(ref: 'Console')
    }
  }
}
{code}

While it is not the goal of this particular feature to enable scripted 
configuration, it does open the possibility for such.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to