You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Karel (JIRA)" <ji...@apache.org> on 2018/08/16 07:56:00 UTC

[jira] [Created] (LOG4J2-2412) Cannot create log4j2 logfile if path contains plus '+' characters - dest tag in configuration

Karel created LOG4J2-2412:
-----------------------------

             Summary: Cannot create log4j2 logfile if path contains plus '+' characters - dest tag in configuration
                 Key: LOG4J2-2412
                 URL: https://issues.apache.org/jira/browse/LOG4J2-2412
             Project: Log4j 2
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.11.1
         Environment: non OS specific - happens on Linux/Windows
            Reporter: Karel


Hello,

In my application I am loading prepared XML configuration for logging.

The configuration contains
{code:java}
// xml
<Configuration status="WARN" dest="/home/kure/MyApp/log/log4j2.log">
....
</Configuration>{code}
 For this case everything is working fine. But I accidentaly put "+" into path
{code:java}
// xml
<Configuration status="WARN" dest="/home/kure/MyApp+/log/log4j2.log">
....
</Configuration>{code}
which starts writing into console:
{code:java}
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.
{code}
 

after some debugging  I found that in class:

org.apache.logging.log4j.core.helpers.FileUtils.java 
{code:java}
// 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);
{code}
line:
{code:java}
// java
return new File(URLDecoder.decode(fileName, "UTF8"));
{code}
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



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)