log.trace() and log.debug() Werenโt Showing โ And How I Fixed ItWhile testing my Spring Boot app, I wanted to log messages at different levels using Lombokโs @Slf4j. But something was off...
I created a class that logs messages when the app starts:
@Slf4j
@Service
public class LogginRunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
log.trace("TRACE ๋ก๊ทธ ๋ฉ์ธ์ง");
log.debug("DEBUG ๋ก๊ทธ ๋ฉ์ธ์ง");
log.info("INFO ๋ก๊ทธ ๋ฉ์ธ์ง");
log.warn("WARN ๋ก๊ทธ ๋ฉ์ธ์ง");
log.error("ERROR ๋ก๊ทธ ๋ฉ์ธ์ง");
}
}
Only these showed in the console:
INFO ๋ก๊ทธ ๋ฉ์ธ์ง
WARN ๋ก๊ทธ ๋ฉ์ธ์ง
ERROR ๋ก๊ทธ ๋ฉ์ธ์ง
But my TRACE and DEBUG logs were completely missing.
Spring Boot sets the default log level to INFO.
This means anything below that (TRACE, DEBUG) wonโt show up unless you manually allow them.
I updated my application.properties:
logging.level.ruby.paper=trace
๐ This tells Spring:
"Show all logs (even the very detailed ones) for anything under the
ruby.paperpackage."
After restarting, all log levels appeared, including TRACE and DEBUG.
You can also target different packages or globally:
# For everything
logging.level.root=debug
# For a specific package
logging.level.com.example.service=debug
| Problem | Fix |
|---|---|
TRACE and DEBUG not showing | Add logging.level.package=trace in application.properties |
| Default log level is too high | Spring Bootโs default is INFO, so lower ones are hidden |
Logging levels help you see just the right amount of info at the right time. If something isnโt showing โ check your logging level first!