Log4j 2
  1. Log4j 2
  2. LOG4J2-742

XInclude not working with relative path

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.1
    • Component/s: None
    • Labels:
      None

      Description

      When using XInclude in a log4j2 configuration, it uses the CWD of the running application instead of the location of the log4j configuration as base.
      I.e. running the application from within eclipse, the CWD of eclipse is used as base for finding the document to be included.

      IMO, the problem is in XmlConfiguration:

                  final InputStream configStream = configSource.getInputStream();
                  try {
                      buffer = toByteArray(configStream);
                  } finally {
                      configStream.close();
                  }
                  final InputSource source = new InputSource(new ByteArrayInputStream(buffer));
                  final Document document = newDocumentBuilder().parse(source);
      

      There is no way the DOMParser can know, where the base should be, because it is just parsing an InputStream and has no file location.

      The fix would be to add source.setSystemId(configSource.getLocation()) before parsing the document.

      1. xinclude-test.patch
        6 kB
        Pascal Chollet
      2. xinclude.patch
        0.8 kB
        Pascal Chollet

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Gary Gregory
            Reporter:
            Pascal Chollet
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development