当前位置:   article > 正文

SpringBoot关闭日志logo图像_springboot启动日志关闭

springboot启动日志关闭

SpringBo关闭日志logo图像

 

主方法

springApplication.run(DemoApplication.class,args);

点击run方法进去可以看到

  1. public static ConfigurableApplicationContext run(Class<?> primarySource, String... args) {
  2. return run(new Class[]{primarySource}, args);
  3. }

调用下面方法

  1. public static ConfigurableApplicationContext run(Class<?>[] primarySources, String[] args) {
  2. return (new SpringApplication(primarySources)).run(args);
  3. }

然后调用 SpringApplication  找到构造方法

  1. public SpringApplication(ResourceLoader resourceLoader, Class... primarySources) {
  2. this.sources = new LinkedHashSet();
  3. this.bannerMode = Mode.CONSOLE;
  4. this.logStartupInfo = true;
  5. this.addCommandLineProperties = true;
  6. this.addConversionService = true;
  7. this.headless = true;
  8. this.registerShutdownHook = true;
  9. this.additionalProfiles = new HashSet();
  10. this.isCustomEnvironment = false;
  11. this.resourceLoader = resourceLoader;
  12. Assert.notNull(primarySources, "PrimarySources must not be null");
  13. this.primarySources = new LinkedHashSet(Arrays.asList(primarySources));
  14. this.webApplicationType = WebApplicationType.deduceFromClasspath();
  15. this.setInitializers(this.getSpringFactoriesInstances(ApplicationContextInitializer.class));
  16. this.setListeners(this.getSpringFactoriesInstances(ApplicationListener.class));
  17. this.mainApplicationClass = this.deduceMainApplicationClass();
  18. }

this.bannerMode = Mode.CONSOLE;   logo处于打开状态

找到成员变量

  1. private Mode bannerMode;

找到类Mode类

 

Banner 接口

  1. @FunctionalInterface
  2. public interface Banner {
  3. void printBanner(Environment environment, Class<?> sourceClass, PrintStream out);
  4. public static enum Mode {
  5. OFF,
  6. CONSOLE,
  7. LOG;
  8. private Mode() {
  9. }
  10. }
  11. }

将状态设置OFF

  1. SpringApplication springApplication = new SpringApplication(DemoApplication.class);
  2. springApplication.setBannerMode(Banner.Mode.OFF);
  3. springApplication.run(args);

运行

 

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/751194
推荐阅读
相关标签
  

闽ICP备14008679号