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

Hierarchical component properties

    XMLWordPrintableJSON

    Details

    • Type: Wish
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.8.2
    • Fix Version/s: None
    • Component/s: Configurators
    • Labels:
      None

      Description

      It would be very nice when configuring multiple appenders with complex configuration to be able to substitute properties defined in the appender section. Being able to create local properties within an appender config would remove the need to have the log filename repeated in each attribute that uses a variant on it.

      The current config only allows properties at the global level thus requires the log filename to be repeated multiple times e.g. in this configuration the string "MyApp.log" must be repeated three times to construct a RollingFileAppender with a delete action.

      <Configuration name="MyApp Configuration" status="ERROR">
        <Properties>
          <Property name="MyAppVersionHeader">%d{yyyy-MM-dd HH:mm:ss.SSS} ${VERSION} log file started\n</Property>
          <Property name="logDir">${sys:MyApp.dir.work}/log</Property>
          <Property name="VERSION">1c91bff2e</Property>
          <Property name="maxArchivedFiles">4</Property>
        </Properties>
          <RollingFile name="MyAppLog" filePattern="${logDir}/MyApp.log.%i" fileName="${logDir}/MyApp.log">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSSZ} %-7level [%logger] &lt;%threadName&gt; %mdc %msg%n%throwable" header="${MyAppVersionHeader}"/>
            <SizeBasedTriggeringPolicy size="100MB"/>
            <DefaultRolloverStrategy min="1" max="2147483647">
              <Delete maxDepth="1" basePath="${logDir}">
                <IfAccumulatedFileCount exceeds="${maxArchivedFiles}"/>
                <IfFileName glob="MyApp.log.*"/>
              </Delete>
            </DefaultRolloverStrategy>
          </RollingFile>
      ...
      </

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              pburrowesOC Paul Burrowes
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: