[
https://issues.apache.org/jira/browse/LOG4J2-3258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17462664#comment-17462664
]
Michael Cramer commented on LOG4J2-3258:
----------------------------------------
we have the same problem that since 2.17.0 the {{fileName}} still contains
placeholders because it is not resolved correctly when used together with a
property definition
{code:java}
<Properties>
<Property
name="fileBaseFolder">${sys:LOGGING_PATH:-$${sys:storage.root}/../../logs/wars/storage}</Property>
</Properties>{code}
and
{code:java}
<RollingFile name="rollingFile" fileName="${fileBaseFolder}/storage.log"
filePattern="${fileBaseFolder}/$${date:yyyy-MM}/storage--%d{yyyy-MM-dd-HH}--%i.log.gz">
....
</RollingFile>{code}
the result will be now with 2.17.0 when the {{LOGGING_PATH}} system variable
is not defined
{code:java}
${sys:storage.root}/../../logs/wars/storage/storage.log{code}
which then results in a failure when trying to create the folders in
RollingFileManager line 732
*note*
the system property {{storage.root}} is set in the application by spring boot
based on the {{webAppRootKey}} parameter which in the end can not be some value
that can be hardcoded as it purely depends on the execution environment. at
least one placeholder needs to be resolved for the filename, either it is the
property that defines the path or any other lookup that will invoke a
{{StrLookup}}
while inspecting the code I see there is a decision based if the plugin is
created with an event or without to change the {{StrSubstitutor}} in
{{PluginManager}} line 183-185, but I'm not sure how to reach this code without
an event to get the correct substitutor
> RollingFile fileName containing variables does not work on 2.17.0
> -----------------------------------------------------------------
>
> Key: LOG4J2-3258
> URL: https://issues.apache.org/jira/browse/LOG4J2-3258
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 2.17.0
> Environment: Java 17, Ubuntu 20.04.
> Reporter: Konstantinos Liakos
> Priority: Major
>
> A configuration like the below has stopped working since 2.17.0. The
> variables that originate from <Properties> are not resolved to their actual
> values.
> {code:xml}
> <Property name="logs_dir">$${env:LOGS_DIRECTORY}</Property> {code}
> {code:xml}
> <RollingFile name="Rolling-${ctx:logFile}"
> fileName="${logs_dir}/${ctx:logFile}"{code}
>
> Works fine on 2.16.0.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)