Package-level log configuration helps you control how much detail your app shows in logs for specific parts. It keeps logs clear and useful.
Package-level log configuration in Spring Boot
logging.level.<package-name>=<log-level>
Replace <package-name> with the Java package you want to configure, like com.example.service.
Replace <log-level> with levels like TRACE, DEBUG, INFO, WARN, ERROR.
com.example.service package.logging.level.com.example.service=DEBUG
logging.level.org.springframework.web=INFO
logging.level.root=WARN
This example sets DEBUG logs for the controller package and ERROR logs for the repository package. When the controller method runs, debug and info logs appear. When the repository method runs, only error logs appear.
application.properties logging.level.com.example.controller=DEBUG logging.level.com.example.repository=ERROR // Sample Spring Boot Controller class package com.example.controller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { private static final Logger logger = LoggerFactory.getLogger(HelloController.class); @GetMapping("/hello") public String sayHello() { logger.debug("Debug: Entering sayHello method"); logger.info("Info: Returning greeting message"); return "Hello, World!"; } } // Sample Spring Boot Repository class package com.example.repository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Repository; @Repository public class DataRepository { private static final Logger logger = LoggerFactory.getLogger(DataRepository.class); public void fetchData() { logger.error("Error: Data fetch failed"); logger.info("Info: This info will not show because level is ERROR"); } }
Package names are case-sensitive and must match your Java package structure exactly.
Use root to set a default log level for all packages.
Changing log levels at runtime may require restarting your Spring Boot app.
Package-level log configuration controls log detail per Java package.
Set it in application.properties using logging.level.<package>=<level>.
This helps focus on important logs and reduce noise.