I have a Spring Boot application which runs a Spring Batch job at regular intervals from a Quartz Scheduler. Every time the job runs information about it is always logged as shown below:
Sep 16, 2019 5:01:56 PM org.springframework.batch.core.launch.support.SimpleJobLauncher$1 run
INFO: Job: [SimpleJob: [name=testJob]] launched with the following parameters: [{jobRunTime=1568649716469}]
Sep 16, 2019 5:01:56 PM org.springframework.batch.core.job.SimpleStepHandler handleStep
INFO: Executing step: [publishRequests]
Sep 16, 2019 5:01:56 PM org.springframework.batch.core.launch.support.SimpleJobLauncher$1 run
INFO: Job: [SimpleJob: [name=testJob]] completed with the following parameters: [{jobRunTime=1568649716469}] and the following status: [COMPLETED]
How can I prevent this from being logged? I am using slf4j with log4j2 for logging. I tried adding this line to my logging properties file so only error messages are logged but this did not work:
logging.level.org.springframework.batch=ERROR
I am using Spring Boot 2.1.2 with Spring Batch 4.1.1.
Here are the dependencies in my log file:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jcl</artifactId>
<version>${slf4j.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
I use the following properties for my logging in a log file called logging.properties:
handlers= java.util.logging.FileHandler
.level= INFO
java.util.logging.FileHandler.pattern = myApp.log
java.util.logging.FileHandler.limit = 10000000
java.util.logging.FileHandler.count = 20
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.level = SEVERE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=[%1$tc] %4$s %2$s: %5$s %n
logging.level.org.springframework.batch=ERROR