I am using Log4j2 for logging with Spring Boot , but it is not creating the log file. Given below is my configuration for Log4j2 and dependencies i added.
Log4j2 configuration -
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
</Console>
<!-- File Appender -->
<File name="File" fileName=".logs/app.log">
<PatternLayout pattern="%d{yyyy-MMM-dd HH:mm:ss a} [%t] %-5level %logger{36} - %msg%n" />
</File>
</Appenders>
<Loggers>
<!-- LOG everything at INFO level -->
<Root level="info">
<AppenderRef ref="Console" />
<AppenderRef ref="File" />
</Root>
<!-- LOG "com.baeldung*" at TRACE level -->
<Logger name="com.ams" level="trace">
<AppenderRef ref="File" />
</Logger>
</Loggers>
</Configuration>
Pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Add Log4j2 Dependency -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
Is there any other configuration or dependency i need to add ? Because according to the blogs on web log4j2 should create the log file with the configuration provided above.