Below version are used 5.3.21 2.7.1 2021.0.3

I am trying to implement logging in spring boot using the log4j2 library. I am facing issue in getting my spring environment properties resolved/interpolated inside my log4j2.xml , This is happening when the log4j2.xml is placed in the configuration gitlab repo and is accessed through spring-cloud-config-server. The log4j2.xml has below contents

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern= "${spring:spring.application.name} -  ${spring:runtime-env} %d{yyyy-MM-dd HH:mm:ss} log4j2-dev %5p %c{1}:%L - %m%n"/>
        </Console>
    </Appenders>
    <Loggers>
        <Root level="INFO">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</configuration>

Here , ${spring:spring.application.name} and ${spring:runtime-env} are defined inside application.yaml in the remote configuration repo. the dependencies used for log4j2 library are below:

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
        <version>2.7.1</version>
 </dependency>

   <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-spring-cloud-config-client</artifactId>
            <version>2.18.0</version>
     </dependency>

And i mention the logging.config property as 'http://localhost:8888/config/application/default/main/log4j2.xml' where localhost:8888/config is the config server running on the system

Note: When I put the log4j2.xml inside the src/main/resources and replace the logging.config property eqaul to classpath:log4j2.xml' , the properties ${spring:spring.application.name} and ${spring:runtime-env} , get resolved to watever defined inside the application.yaml . Please let me know if any other information is also needed.

Comment From: ryanjbaxter

Are you using spring.config.import to specify the config server as a configuration source?

Comment From: aditi9991

Yes,I am using the spring.config.import property eqaul to 'optional:configserver:http://localhost:8888/config'

Comment From: ryanjbaxter

Could you try using bootstrap instead and see if it makes a difference? https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#config-first-bootstrap

Comment From: spring-cloud-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-cloud-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.