Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.10.0, 2.11.1
-
None
-
None
-
non OS specific - happens on Linux/Windows
Description
Hello,
In my application I am loading prepared XML configuration for logging.
The configuration contains
// configuration.xml <Configuration status="WARN" dest="/home/kure/MyApp/log/log4j2.log"> .... </Configuration>
For this case everything is working fine. But I accidentaly put "+" into path
// configuration.xml <Configuration status="WARN" dest="/home/kure/MyApp+/log/log4j2.log"> .... </Configuration>
which starts writing into console:
2018-08-16 08:40:49,668 main ERROR File could not be found at [/home/kure/MyApp+/log/log4j2.log]. Falling back to default of stdout.
after some debugging I found that in class:
org.apache.logging.log4j.core.helpers.FileUtils.java
// org.apache.logging.log4j.core.helpers.FileUtils.java String fileName = uri.toURL().getFile(); if (new File(fileName).exists()) { // LOG4J2-466 return new File(fileName); // allow files with '+' char in name } fileName = URLDecoder.decode(fileName, charsetName);
line:
// org.apache.logging.log4j.core.helpers.FileUtils.java //home/kure/.m2/repository/org/apache/logging/log4j/log4j-core/2.11.0/log4j-core-2.11.0-sources.jar!/org/apache/logging/log4j/core/util/FileUtils.java:91 return new File(URLDecoder.decode(fileName, "UTF8"));
converts "+" to " " (space).
Workaround for this problem is to manually create the file.
Until now I rely on that log4j will automatically create the missing files. - Is this a bad habbit?
This is happening only for "configuration's element dest". Appenders (RollingFiles) are not affected by this issue.
As mentioned in your source code this issue is very similar to LOG4J2-466
Thanks for your respond
Karel Cerman
updated:
If i use more crazy path like
// configuration.xml <Configuration status="WARN" dest="/home/kure/MyApp + someFile/log/log4j2.log"> .... </Configuration>
Then even workaround with creating file on path not works -> priority increase
Thanks for message
Karel Cerman