Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2600

Declarative Groovy Configuration DSL

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Configurators
    • Labels:
      None

      Description

      Borrowing the general Groovy syntax used in Stapler, 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:

      <?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>
      

      This would look like this in the declarative Groovy DSL:

      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')
          }
        }
      }
      

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mattsicker Matt Sicker
                Reporter:
                mattsicker Matt Sicker
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m