pjj
pjj

Reputation: 2135

Spring boot - How to get framework logging for WARN and application logging to DEBUG

I am using Spring Boot with Logback for logging. Currently, we have root logger set to DEBUG and then we have app package logger like com.abc.xyz set to DEBUG.

Now, what's happening is all frameworks - Hibernate, Spring etc. are printing their DEBUG logs. What we want that all framework should print only WARN and below logs, so below are 2 options which I am thinking:

Option 1: Set the ROOT logger to WARN. However I am not sure what are its implications and even not sure whether it will help in achieving what I am looking for or not.

Option 2: Create specific loggers like org.springframework and org.hibernate and set them to WARN.

My questions:

Upvotes: 4

Views: 3290

Answers (1)

Smajl
Smajl

Reputation: 8015

In Spring Boot, ERROR, WARN and INFO levels are always printed as default for both the root logger and all dependencies.

If you wish to print additional logs, you need to specify that in your application.properties:

logging.level.org.hibernate=DEBUG
logging.level.com.abc.xyz=DEBUG

If you set your ROOT logger to WARN, you will only see warning and error messages (unless you override this setting for different package).

I would suggest leaving the default settings for all Spring-related dependencies since this will allow you to see all info, warning and error messages. If you really need to see just warning and error messages, set the root logger to WARN.

Then, you can specify any other classes to log to DEBUG in your properties.

Upvotes: 2

Related Questions