An error occurs when springboot sets the log level [How to Solve]

Configure the springboot log. The output level is info. An error is reported when running:

Caused by: Failed to bind properties under 'logging.level' to java.util.Map<java.lang.String, java.lang.String>
    at org.springframework.boot.context.logging.LoggingApplicationListener.setLogLevels(
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeFinalLoggingLevels(
    at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(

The application.yml file is configured as follows:


    console: "%d - %msg%n" #     Define the format of the log to be printed
# dateformat: # Set the log date format
# file: # Defines the log format for output to the log file
# config: # The location of the logging configuration file. For example, classpath:logback.xml.
  file: E:/sell/sell.log # Set the log file where the logs are saved
# max-history:
# max-size: # Set the maximum size of the log file # Set the log level
# path:/# location of the log file, e.g. /var/log
  register-shutdown-hook: false # Register a shutdown hook for the logging system when it is initialized.
  level: info

The reason is that the log level is configured incorrectly. It should be configured as

    root: info

The reasons are as follows:

Find the logging log level configuration shown in the following figure in the official document. The official address is: -Features custom log levels

roughly means that we can use trace,   DEBUG,   INFO,   WARN,   ERROR,   FATAL,   perhaps   Off to specify the spring project log level. Its format is:
logging. Level. < logger-name>=< level>
therefore, we need to configure a logger name when configuring the log level, so we can specify a root or a package path as shown in the figure above. Configuring logging. Level. Root = warn means configuring the root logger, so the following configuration ideas are:
logging. Level. Root = warn
The configuration of logging. Level. Org. Hibernate = error
is that org.springframework.web is the debug level, org.hibernate is the error level, and the log output level of other projects is warn


Similar Posts: