ppkarwasz opened a new issue, #4348:
URL: https://github.com/apache/logging-log4j2/issues/4348

   ## Description
   
   `Log4j1ConfigurationConverter` writes the **resolved** values of `${...}` 
variables into the converted configuration,
   instead of translating them.
   
   The converter shares `Log4j1ConfigurationParser` with the runtime 
`Log4j1ConfigurationFactory`.
   `Log4j1ConfigurationParser.getProperty` calls `OptionConverter.substVars`,
   which resolves each variable first from `PropertiesUtil` (system properties 
and the other Log4j property sources)
   and only then from the properties file itself.
   
   At runtime this is the correct Log4j 1 behavior. For a conversion tool it is 
not:
   
   - the output depends on the machine the converter runs on,
     and captures its system properties (user names, paths, or anything else 
set with `-D`);
   - the output loses the indirection: `${catalina.base}/logs/app.log` becomes 
a fixed path
     instead of `${sys:catalina.base}/logs/app.log`.
   
   Expected behavior: when converting, variables should be translated to the 
equivalent Log4j 2 lookup
   (`${sys:...}`, or a `<Property>` for variables defined in the file) rather 
than resolved.
   The runtime `Log4j1ConfigurationFactory` should keep its current semantics.
   
   ## Configuration
   
   **Version:** 2.26.1 (and `2.x` at `d631e82`)
   
   **Operating system:** any
   
   **JDK:** any
   
   ## Logs
   
   None.
   
   ## Reproduction
   
   ```properties
   log4j.rootLogger=INFO, FILE
   log4j.appender.FILE=org.apache.log4j.FileAppender
   log4j.appender.FILE.File=${user.home}/app.log
   log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
   ```
   
   Converting this file with `Log4j1ConfigurationConverter` produces a 
`fileName` containing
   the home directory of the user running the converter, instead of 
`${sys:user.home}/app.log`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to