Custom Banners with Spring Boot

Learn How to change or customize the Spring Boot application startup banner or logo.

Overview

This is a quick tutorial on customizing Spring Boot Banner. Spring Boot Banner is the Spring Boot official logo we see in the console or logs when we launch a Spring Boot application.

Spring Boot allows us to easily customize this banner by changing the banner dimensions and using custom banner logos.

If you wish to disable the banner, refer to How to Disable Spring Boot Banner.

Generate Spring Boot Custom Banner

Spring Boot banners are plain text files containing ASCII characters art. Many online tools help us generate an ASCII text representation of a given image or text.

Here is an example of the ‘amitph‘ logo in the text format. We can save this text in a file named banner.txt.

Spring Boot. Custom Banner | amitph

Spring Boot Custom Banner using banner.txt

By default, Spring Boot looks for a banner.txt file under the ‘src/main/resources‘ directory. Thus, the most basic way of customizing the Spring Boot banner is to create a logo in a banner.txt file and place that file under the ‘src/main/resources‘ directory.

Alternatively, we can provide the custom name and location if we want to name the file differently or place it elsewhere on the machine.

spring:
  banner:
    location: classpath:/path/to/banner/file/ourbanner.txtCode language: YAML (yaml)

Spring Boot Custom Banner using Images

Moreover, Spring Boot also allows us to provide images as banners. Currently, it supports png, jpg, or gif format images.

To use images as custom banners, we can keep the logos in banner.jpg, banner.png, or banner.gif under the resources directory.

On top of that, we can also control the banner dimensions and properties like width, height, margin, invert etc.

spring:
 banner:
   image:
     width: 50
     height: 15
     margin: 10
     invert: falseCode language: YAML (yaml)

Suppose we have both the banner.txt file and the banner image file, Spring Boot prints one after the other. We can also see the image banner dimensions are correctly applied.

                 .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
               @@    *@@@@                @@ @@@@@@ @@@     
            @@@    @@@@@@                  @@@@@@@@    @@@  
            @@@   @@@@@@@@@                            .@   
              @@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@      @@     
                 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@       
                   @@.                 @@@@@@@@@@@@         
                     @@@                     @@@@           
                       *@@@@@@@@@@       :@@@@              
                          @@  &@@@@@@@@@@ @@                
                            @@@        @@@                  
                              @@@    @@@                    
                                *@@@@@                      
                                                            

                                                                  .  .
    ,@@@@@@@@                                                    ******                                   /@@@@#               &@@@@@@@%
   %@@@@#(((                                                       */     .@@@@@                          /@@@@#                 (((@@@@@
   ,@@@@(        *#***@**#*      *****,*#**@*.&    @ *&%***      ......   .@@@@       (**** # */(* (      /@@@@# &**@(*(*           ,@@@@&
   ,@@@@(      @@@@@@@@@@@@@@    &@@@@@@@@@@@@@@#@@@@@@@@@@@&    //**/*/@@@@@@@@@@@    @@@@@@@@@@@@@@@,   /@@@@@@@@@@@@@@@(         ,@@@@&
   ,@@@@(       .#      #@@@@@   &@@@@@,     @@@@@@&    @@@@@@   //**/*   .@@@@@       @@@@@/     &@@@@@# /@@@@@@     #@@@@&        ,@@@@&
 &@@@@@@         ,%@@@@@@@@@@@&  &@@@@       *@@@@(      .@@@@#  //**/*   .@@@@@       @@@@@       /@@@@# /@@@@#.      .@@@@,       *@@@@@@
 ,@@@@@@/     (@@@@@@/////@@@@&  &@@@@#      *@@@@(       @@@@#  //**/*   .@@@@@       @@@@@       /@@@@# /@@@@#       .@@@@,       %@@@@@@&
   ,@@@@(      @@@@.    ,(@@@@&  &@@@@#      *@@@@(       @@@@#  //*//*   .@@@@@   ,   @@@@@/*   .#@@@@@# /@@@@#       .@@@@,       ,@@@@&
   ,@@@@(      (@@@@@@@@@@@@@@&  &@@@@#      *@@@@(       @@@@#  //**/*    #@@@@@@@@&  @@@@@@@@@@@@@@@,   /@@@@#       .@@@@,       ,@@@@&
   ,@@@@(         %    @ ,                                                         #   @@@@  @    &                                 ,@@@@&
   %@@@@@@%%#                                                                          @@@@                                     ,%%@@@@@(
      @@@@@@(                                                                          @@@@                                    /@@@@@@%@Code language: plaintext (plaintext)

One thing to note is that image banners slow down the Spring Boot startup. This is because Spring Boot, upon every startup, converts the image (jpg, png, or gif) into ASCII text. Some complex images can badly affect the startup time. Hence, it is better to use banner.txt files for customizing the Spring boot banners.

Summary

We covered examples of customizing Spring Boot startup Banners using plain text banners and custom images as banners. By default, Spring looks for a banner file (banner.txt, banner.jpg, banner.png, or banner.gif) in the resources directory. However, we can provide files with custom names and paths. Also, we can customize the banner image dimension like width, height, and margin.

You can refer to our GitHub Repository for the complete source code of the examples used in this tutorial.