[问题记录] spring-boot 打印启动时间
2017-11-02 10:09
513 查看
问题
spring-boot 工程启动结束会打印启动时间
最近新建一个工程发现启动完后并没有打印上面的那句话
解决
查看源码,发现打印日志在
其打印是的info级日志,而我在logback配置启动类Application包的别类是WARN级别的,所以它并不打印时间,把启动类Application所在包日志级别改为info即可。
spring-boot 工程启动结束会打印启动时间
Started Application in 12.805 seconds (JVM running for 20.686)
最近新建一个工程发现启动完后并没有打印上面的那句话
解决
查看源码,发现打印日志在
public ConfigurableApplicationContext run(String... args) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); ConfigurableApplicationContext context = null; FailureAnalyzers analyzers = null; configureHeadlessProperty(); SpringApplicationRunListeners listeners = getRunListeners(args); listeners.starting(); try { ApplicationArguments applicationArguments = new DefaultApplicationArguments( args); ConfigurableEnvironment environment = prepareEnvironment(listeners, applicationArguments); Banner printedBanner = printBanner(environment); context = createApplicationContext(); analyzers = new FailureAnalyzers(context); prepareContext(context, environment, listeners, applicationArguments,printedBanner); //著名的refresh refreshContext(context); afterRefresh(context, applicationArguments); listeners.finished(context, null); stopWatch.stop(); //打印启动时间日志 if (this.logStartupInfo) { new StartupInfoLogger(this.mainApplicationClass) .logStarted(getApplicationLog(), stopWatch); } return context; } catch (Throwable ex) { handleRunFailure(context, listeners, analyzers, ex); throw new IllegalStateException(ex); } }
public void logStarted(Log log, StopWatch stopWatch) { if (log.isInfoEnabled()) { log.info(getStartedMessage(stopWatch)); } }
其打印是的info级日志,而我在logback配置启动类Application包的别类是WARN级别的,所以它并不打印时间,把启动类Application所在包日志级别改为info即可。
相关文章推荐
- 解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE
- 解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE(转)
- spring boot aop 记录方法执行时间
- Spring Boot Spring MVC Rest json输出日期为时间戳的问题
- spring boot成功启动后访问报错404的问题
- spring-boot 使用 main函数 无法启动的问题完美 解决方案。
- Idea使用Maven创建多模块SpringBoot项目问题记录
- 通过实例及源码分析关于SpringBoot启动类启动时自动配置问题
- 创建spring boot项目启动报错遇到的问题
- SpringBoot web demo项目启动后立马自动关闭问题解决办法
- spring boot成功启动后访问报错404的问题
- spring boot成功启动后访问报错404的问题
- 解决SpringBoot项目打成jar包访问不了jsp模板的问题: SpringBoot项目集成jsp模板打成war包 然后通过java -jar 命令启动访问
- 解决maven同步的eclipse中的springboot项目无法启动问题
- springboot返回时间问题
- SpringBoot小问题记录
- Spring Boot学习记录(四)--问题记录
- Spring Boot项目在Mac下使用Maven启动时碰到的神奇问题:Unregistering JMX-exposed beans on shutdown
- Spring Boot启动出现Failed to load class "org.slf4j.impl.StaticLoggerBinder"的问题
- spring boot正常启动后,页面报404问题