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

Enable XInclude for XML configurations

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-beta9
    • Component/s: Configurators
    • Labels:
      None
    • Environment:

      Description

      Enable XInclude for XML configurations.

      See org.apache.logging.log4j.core.config.XMLConfigurationTest

      For example:

      <?xml version="1.0" encoding="UTF-8"?>
      <configuration xmlns:xi="http://www.w3.org/2001/XInclude"
        status="warn" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
        <properties>
          <property name="filename">target/test.log</property>
        </properties>
        <ThresholdFilter level="debug"/>
        <xi:include href="target/test-classes/log4j-xinclude-appenders.xml" />
        <xi:include href="target/test-classes/log4j-xinclude-loggers.xml" />
      </configuration>
      log4j-xinclude-appenders.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <appenders>
        <Console name="STDOUT">
          <PatternLayout pattern="%m%n" />
        </Console>
        <File name="File" fileName="${filename}" bufferedIO="false">
          <PatternLayout>
            <pattern>%d %p %C{1.} [%t] %m%n</pattern>
          </PatternLayout>
        </File>
        <List name="List">
          <filters>
            <ThresholdFilter level="error" />
          </filters>
        </List>
      </appenders>
      
      log4j-xinclude-loggers.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <loggers>
        <logger name="org.apache.logging.log4j.test1" level="debug" additivity="false">
          <ThreadContextMapFilter>
            <KeyValuePair key="test" value="123" />
          </ThreadContextMapFilter>
          <appender-ref ref="STDOUT" />
        </logger>
      
        <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
          <appender-ref ref="File" />
        </logger>
      
        <root level="error">
          <appender-ref ref="STDOUT" />
        </root>
      </loggers>
      

        Issue Links

          Activity

          Hide
          garydgregory Gary Gregory added a comment -

          Commit feature:

          commit -m "[LOG4J2-341] Enable XInclude for XML configurations." (6 paths specified)
              Sending        C:/vcs/svn/apache/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
              Sending        C:/vcs/svn/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/config/XMLConfigurationTest.java
              Adding         C:/vcs/svn/apache/log4j2/trunk/core/src/test/resources/log4j-xinclude-appenders.xml
              Adding         C:/vcs/svn/apache/log4j2/trunk/core/src/test/resources/log4j-xinclude-loggers.xml
              Adding         C:/vcs/svn/apache/log4j2/trunk/core/src/test/resources/log4j-xinclude.xml
              Sending        C:/vcs/svn/apache/log4j2/trunk/src/changes/changes.xml
              Transmitting file data ...
              Committed revision 1512556.
          

          But, the XML configuration code now incorrectly complains, for example

          2013-08-09 23:33:16,085 ERROR appenders contains an invalid element or attribute "xml:base"
          2013-08-09 23:33:16,090 ERROR loggers contains an invalid element or attribute "xml:base"
          

          The "xml:base" attribute is part of the XML standards used by XInclude. I'll ask on the ML...

          Show
          garydgregory Gary Gregory added a comment - Commit feature: commit -m "[LOG4J2-341] Enable XInclude for XML configurations." (6 paths specified) Sending C:/vcs/svn/apache/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java Sending C:/vcs/svn/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/config/XMLConfigurationTest.java Adding C:/vcs/svn/apache/log4j2/trunk/core/src/test/resources/log4j-xinclude-appenders.xml Adding C:/vcs/svn/apache/log4j2/trunk/core/src/test/resources/log4j-xinclude-loggers.xml Adding C:/vcs/svn/apache/log4j2/trunk/core/src/test/resources/log4j-xinclude.xml Sending C:/vcs/svn/apache/log4j2/trunk/src/changes/changes.xml Transmitting file data ... Committed revision 1512556. But, the XML configuration code now incorrectly complains, for example 2013-08-09 23:33:16,085 ERROR appenders contains an invalid element or attribute "xml:base" 2013-08-09 23:33:16,090 ERROR loggers contains an invalid element or attribute "xml:base" The "xml:base" attribute is part of the XML standards used by XInclude. I'll ask on the ML...
          Hide
          garydgregory Gary Gregory added a comment -

          Closing, LOG4J2-342 is fixed.

          Show
          garydgregory Gary Gregory added a comment - Closing, LOG4J2-342 is fixed.
          Hide
          jahutton James Hutton added a comment -

          when using xinclude the path is interpreted as relative to the base directory, not the file including the additional configuration. Classpath protocol is not usuable either.

          Show
          jahutton James Hutton added a comment - when using xinclude the path is interpreted as relative to the base directory, not the file including the additional configuration. Classpath protocol is not usuable either.
          Hide
          jahutton James Hutton added a comment -

          Classpath as in any sort of virtualized mapping of where it should start as base.

          Show
          jahutton James Hutton added a comment - Classpath as in any sort of virtualized mapping of where it should start as base.

            People

            • Assignee:
              Unassigned
              Reporter:
              garydgregory Gary Gregory
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development