0

I am trying to use log4j2 with Spring Boot (2.0.3).

I have added below dependency in my pom file and excluded spring-boot-starter-logging as well:

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

The problem is when I deploy my war on tomcat, and put the config file with name log4j2.xml on class path(WEB-INF/classes) logs are getting generated. But If I am trying to use a different file name by putting below property in application.properties, it is not working.

logging.config=classpath:mylog4j2.xml

I have put mylog4j2 in the same folder (WEB-INF/classes) as log4j2, but still logs are not getting generated.

Also I am not allowed to set config path using command line arguments and have to use property file only.

Can anyone please help me out.

Anjum
  • 1
  • Also, when I am running the same code from eclipse using this property (logging.config=mylog4j2.xml), logs are getting generated successfully. – Anjum Nov 16 '18 at 12:04
  • application.properties are not system properties. Try this out: https://stackoverflow.com/a/36896400/1235935. Or else pass the property in the java command line used to start the app. `-Dlogging.config=classpath:mylog4j2.xml` – Saptarshi Basu Dec 05 '18 at 06:42

0 Answers0