Kim created LOG4J2-888:
--------------------------

             Summary: Specifying log4jConfiguration in web.xml fails on Windows 
when the file's path contains spaces
                 Key: LOG4J2-888
                 URL: https://issues.apache.org/jira/browse/LOG4J2-888
             Project: Log4j 2
          Issue Type: Bug
    Affects Versions: 2.1
         Environment: Windows 7, Apache Tomcat 7, Java 7
            Reporter: Kim
            Priority: Minor


When specifying the context parameter log4jConfiguration in the web.xml of a 
web application and the resulting string contains spaces, e.g.

{code:xml}
    <context-param>
        <param-name>log4jConfiguration</param-name>
        
<param-value>file:///${sys:catalina.base}/conf/logtestapp-log4j.xml</param-value>
    </context-param>
{code}

the following exception is thrown on Windows systems:

{code}
ERROR StatusLogger Unable to convert configuration location [file:///C:\Program 
Files\Apache Software 
Foundation\apache-tomcat-7.0.54/conf/logtestapp-log4j.xml] to a URI 
java.net.URISyntaxException: Illegal character in path at index 18: 
file:///C:/Program Files/Apache Software 
Foundation/apache-tomcat-7.0.54/conf/logtestapp-log4j.xml
        at java.net.URI$Parser.fail(URI.java:2829)
        at java.net.URI$Parser.checkChars(URI.java:3002)
        at java.net.URI$Parser.parseHierarchical(URI.java:3086)
        at java.net.URI$Parser.parse(URI.java:3034)
        at java.net.URI.<init>(URI.java:595)
        at 
org.apache.logging.log4j.core.util.FileUtils.getCorrectedFilePathUri(FileUtils.java:116)
        at 
org.apache.logging.log4j.web.Log4jWebInitializerImpl.getConfigURI(Log4jWebInitializerImpl.java:193)
        at 
org.apache.logging.log4j.web.Log4jWebInitializerImpl.initializeNonJndi(Log4jWebInitializerImpl.java:156)
        at 
org.apache.logging.log4j.web.Log4jWebInitializerImpl.start(Log4jWebInitializerImpl.java:107)
        at 
org.apache.logging.log4j.web.Log4jServletContainerInitializer.onStartup(Log4jServletContainerInitializer.java:57)
{code}

Substituting spaces with %20 seems to solve the problem:
{code:xml}
    <context-param>
        <param-name>log4jConfiguration</param-name>
        
<param-value>file:///C:/Program%20Files/Apache%20Software%20Foundation/apache-tomcat-7.0.54/conf/logtestapp-log4j.xml</param-value>
    </context-param>
{code}
but this will require using fixed strings instead of lookup values.

Note: This bug appears to be very similar to LOG4J2-409.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to