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

Specifying log4jConfiguration in web.xml fails on Windows when using ${user.home}

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0-beta8
    • 2.0-rc1
    • None
    • None
    • Windows 7, Apache Tomcat 7, Java 7

    Description

      When specifying the context parameter log4jConfiguration in the web.xml of a web application and using ${user.home} as part of the path, e.g.

      <context-param>
          <param-name>log4jConfiguration</param-name>
          <param-value>file://${user.home}/someDirectory/log4j2.xml</param-value>
      </context-param>
      

      the following exception is thrown on Windows systems:

      java.net.URISyntaxException: Illegal character in authority at index 7: file://C:\Users\steinman/someDirectory/log4j2.xml
          at java.net.URI$Parser.fail(Unknown Source)
          at java.net.URI$Parser.parseAuthority(Unknown Source)
          at java.net.URI$Parser.parseHierarchical(Unknown Source)
          at java.net.URI$Parser.parse(Unknown Source)
          at java.net.URI.<init>(Unknown Source)
          at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:46)
          ...
      

      It is because of the backslashes that are not allowed in URIs.

      There is an example in the documentation using backslashes (http://logging.apache.org/log4j/2.x/manual/webapp.html) which will produce the same exception.

      Attachments

        1. LOG4J2-409.patch
          2 kB
          Thomas Neidhart

        Activity

          People

            beamerblvd Nick Williams
            stoney00 Frank Steinmann
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: