title: log4j2 spring boot lookup can't read property from application.properties
body: <p>I want log4j2-spring.xml to read a property from the application.properties file. But seems log4j2-spring.xml is unable to read this. I have read <a href="https://logging.apache.org/log4j/2.x/manual/lookups.html#SpringLookup" rel="nofollow noreferrer">https://logging.apache.org/log4j/2.x/manual/lookups.html#SpringLookup</a> to implement this.</p>
  <p>I have seen <a href="https://stackoverflow.com/a/60504812/2952011">this answer</a> on this site. Tried like this as well. But it didn't help me.</p>
  <p>My build.gradle is like this:</p>
  <pre><code>plugins {
      id 'org.springframework.boot' version '2.5.0-SNAPSHOT'
      id 'io.spring.dependency-management' version '1.0.11.RELEASE'
      id 'java'
  }
  
  group = 'com.example'
  version = '0.0.1-SNAPSHOT'
  sourceCompatibility = '1.8'
  
  repositories {
      mavenCentral()
      maven { url 'https://repo.spring.io/milestone' }
      maven { url 'https://repo.spring.io/snapshot' }
  }
  
  ext {
      log4j2version = '2.14.1'
  }
  
  dependencies {
  
      compileOnly 'org.projectlombok:lombok:1.18.18'
      annotationProcessor 'org.projectlombok:lombok:1.18.18'
  
      implementation 'org.springframework.boot:spring-boot-starter'
      implementation 'org.springframework.boot:spring-boot-starter-log4j2'
  
      implementation &quot;org.apache.logging.log4j:log4j-spring-cloud-config-client:${log4j2version}&quot;
      implementation &quot;org.apache.logging.log4j:log4j-api:${log4j2version}&quot;
      implementation &quot;org.apache.logging.log4j:log4j-core:${log4j2version}&quot;
  }
  
  configurations {
      all {
          exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
          exclude group: &quot;ch.qos.logback&quot;, module: &quot;logback-classic&quot;
          exclude group: &quot;org.springframework.cloud&quot;, module: &quot;spring-cloud-bus&quot;
      }
  }
  </code></pre>
  <p>application.properties file is:</p>
  <pre><code>commission.base.path1=C:/Users/user1/Downloads/demo1
  logging.config=classpath:log4j2-spring.xml
  
  spring.cloud.config.enabled=false
  </code></pre>
  <p>log4j2-spring.xml is like this:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;configuration&gt;
      
      &lt;Appenders&gt;
          &lt;Console name=&quot;console&quot; target=&quot;SYSTEM_OUT&quot;&gt;
              &lt;PatternLayout pattern=&quot;%d{yyyy-MM-dd HH:mm:ss:SSS} [%thread] %-5level %logger{2}:%L - %msg%n&quot;/&gt;
          &lt;/Console&gt;
  
          &lt;RollingFile name=&quot;CATALINA-FILE&quot; fileName=&quot;$${spring:commission.base.path1}/logs/catalina.log&quot;
                       filePattern=&quot;$${spring:commission.base.path1}/logs/archived/catalina_%d{yyyy-MM-dd}.log.gz&quot;&gt;
              &lt;PatternLayout&gt;
                  &lt;Pattern&gt;%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{20}:%L - %msg%n&lt;/Pattern&gt;
              &lt;/PatternLayout&gt;
              &lt;Policies&gt;
                  &lt;TimeBasedTriggeringPolicy interval=&quot;1&quot;/&gt;
                  &lt;SizeBasedTriggeringPolicy size=&quot;1 GB&quot; /&gt;
              &lt;/Policies&gt;
          &lt;/RollingFile&gt;
      &lt;/Appenders&gt;
  
      &lt;Loggers&gt;
          &lt;root level=&quot;debug&quot;&gt;
              &lt;appender-ref ref=&quot;CATALINA-FILE&quot;/&gt;
              &lt;appender-ref ref=&quot;console&quot;/&gt;
          &lt;/root&gt;
      &lt;/Loggers&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p>But everytime I run the code, I am getting this exception:</p>
  <pre><code>2021-05-21 21:28:38,409 main ERROR Unable to create file ${spring:commission.base.path1}/logs/catalina.log java.io.IOException: The filename, directory name, or volume label syntax is incorrect
      at java.io.WinNTFileSystem.canonicalize0(Native Method)
      at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:428)
      at java.io.File.getCanonicalPath(File.java:618)
      at java.io.File.getCanonicalFile(File.java:643)
      at org.apache.logging.log4j.core.util.FileUtils.makeParentDirs(FileUtils.java:135)
      at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:720)
      at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:704)
      at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
      at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:100)
      at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:217)
      at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:146)
      at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:62)
      at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1000)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:940)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:932)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:551)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
      at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:287)
      at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:627)
      at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:304)
      at org.apache.logging.log4j.spring.boot.Log4j2CloudConfigLoggingSystem.loadConfiguration(Log4j2CloudConfigLoggingSystem.java:123)
      at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.loadConfiguration(Log4J2LoggingSystem.java:181)
      at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
      at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
      at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.initialize(Log4J2LoggingSystem.java:163)
      at org.apache.logging.log4j.spring.boot.Log4j2CloudConfigLoggingSystem.initialize(Log4j2CloudConfigLoggingSystem.java:80)
      at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:312)
      at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:281)
      at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
      at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
      at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
      at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
      at java.util.ArrayList.forEach(ArrayList.java:1259)
      at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
      at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
      at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
      at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:373)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:331)
      at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:144)
      at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:212)
      at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117)
      at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
      at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
      at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
      at java.util.ArrayList.forEach(ArrayList.java:1259)
      at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
      at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
      at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
      at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:373)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:331)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
      at com.example.demo1.Demo1Application.main(Demo1Application.java:12)
  </code></pre>
  <p>How to solve this? Thanks in advance.</p>