nav3916872
nav3916872

Reputation: 998

Spring Boot Logging Configuration

Is there a way to disable Spring boot logs and print only the logs which i give in the program using logger.info or logger.debug statements. I mean i want only the log statements which i had given in the program to be logged and nothing else. I use the default logging system given by spring boot. If required i can change to log4j or log4j2 as well. Using spring-boot version 1.2.7. In other way, putting forward , like logging.level.org.springframework can be used to log spring related logs ,is there a way like logging.level.applicationlevel to get application(Java logger statement) logs alone

Upvotes: 2

Views: 2129

Answers (2)

Rakesh
Rakesh

Reputation: 1434

You can configure logging properties as follows:

logging.level.* = ERROR
logging.level.package_name=DEBUG

Example:
logging.level.com.example.controller=DEBUG

So classes under com.example.controller package will be logged, others only on error will be logged.

I hope this helped!!

Upvotes: 0

SMA
SMA

Reputation: 37023

You can configure your logging in your application.properties like below:

logging.level.com.myapp.packagename=INFO
logging.level.org.springframework=ERROR

INFO means it will print logging of classes in your package and all sub package at INFO/ERROR/WARN level, while for spring related classes only print if there are ERROR level logging.

Upvotes: 6

Related Questions