springboot @Slf4j only displays Error log, not INFO log and DEBUG log

problem:

springboot uses @Slf4j annotated log.debug(), log.info(), log.error() to only display ERROR logs, not DEBUG and INFO logs.

 

the reason:

There is a problem with the logging.level.* setting in application.properties, and the setting becomes

logging.level.root=warn

So only warn, error, fatal logs are displayed,

 

solve:

Modify logging.level.root=warn in the application.properties file to

logging.level.root=info

Or comment out this line, because the default log level is info,

 

Explanation:

1. Log level

 trace<debug<info<warn<error<fatal

Display the log level greater than or equal to the setting. For example, if you set info, it will display info, warn, error, fatal, but not  trace and debug.

2. Scope

logging.level.root=info

The root here stands for the root directory, and the scope is the entire project.

You can also modify root to a specific package name, and the scope of action is all classes under the package.

E.g:

logging.level.com.example.controller=debug

Then the debug, info, warn, error, fatal logs of all classes under the com.example.controller package can be displayed

Multiple settings can also be superimposed to use,

E.g:

logging.level.root=warn

logging.level.com.example.controller=debug

Then the debug, info, warn, error, fatal logs of all classes under the com.example.controller package can be displayed

Other categories only display warn, error, fatal logs

 

Guess you like

Origin blog.csdn.net/abcdu1/article/details/109625144