Configure the springboot log. The output level is info. An error is reported when running:
Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'logging.level' to java.util.Map<java.lang.String, java.lang.String> at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:250) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:226) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:210) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:166) at org.springframework.boot.context.logging.LoggingApplicationListener.setLogLevels(LoggingApplicationListener.java:307) at org.springframework.boot.context.logging.LoggingApplicationListener.initializeFinalLoggingLevels(LoggingApplicationListener.java:290) at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:238) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:200) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:173) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
The application.yml file is configured as follows:
logging: pattern: 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
level: 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: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot -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
logging.level.org.springframework.web=DEBUG
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:
- [Exception] LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either r…
- [Solved] Logback configuration error: SLF4J: Class path contains multiple SLF4J bindings.
- java.lang.IllegalStateException: Failed to load property source from location ‘classpath:/application-dev.yml’
- Springboot starts with @ scheduled and reports an error: no qualifying bean
- org.springframework.core.log.LogMessage [How to Solve]
- Failed to bind properties under
- Springboot Failed to parse configuration class [x]
- The Tomcat connector configured to listen on port 8080 failed to start.
- [Solved] ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
- [Solved] linux Error: springboot org.springframework.context.ApplicationContextException: Failed to start bean ‘webServerStartStop’