Spring Boot
Banner Customization
Spring Boot displays an ASCII art banner at startup — the Spring logo by default. The banner is fully customizable: replace it with your own ASCII art, add application version and environment information, change its color, log it to a file instead of the console, or disable it entirely. Small detail, real impact on developer experience and deployment identification.
The Default Banner
Every Spring Boot application prints an ASCII art banner to the console at startup. The default banner shows the Spring logo and the Spring Boot version. It serves a practical purpose beyond aesthetics — it immediately confirms which application started, which version is running, and on which Java version. In a terminal with multiple running services, a distinctive banner identifies the application instantly.
Java
// Default Spring Boot banner output at startup:
//
// . ____ _ __ _ _
// /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
// ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
// \/ ___)| |_)| | | | | || (_| | ) ) ) )
// ' |____| .__|_| |_|_| |_\__, | / / / /
// =========|_|==============|___/=/_/_/_/
// :: Spring Boot :: (v3.2.4)
//
// The banner prints before any beans are created — it is the very first
// visible output when a Spring Boot application starts.
// Location in code: SpringApplication.run() → printBanner()
// Rendered by: SpringApplicationBannerPrinter
// Default banner class: SpringBootBannerCustom Text Banner — banner.txt
Replace the default banner by creating a banner.txt file in src/main/resources. Spring Boot detects it automatically and prints it instead of the default Spring logo.
Java
// Create: src/main/resources/banner.txt
// Content is printed as-is — use any ASCII art generator online
// Simple example:
// __ __ _
// | \/ |_ _ / \ _ __ _ __
// | |\/| | | | |/ _ \ | '_ \| '_ \
// | | | | |_| / ___ \| |_) | |_) |
// |_| |_|\__, /_/ \_\ .__/| .__/
// |___/ |_| |_|
//
// Version: ${application.version}
// Spring Boot: ${spring-boot.version}
// Java: ${java.version}
// Banner variables — Spring Boot replaces these at runtime:
// ${application.version} → version from MANIFEST.MF (1.0.0)
// ${application.formatted-version} → (v1.0.0) — with parentheses
// ${spring-boot.version} → Spring Boot version (3.2.4)
// ${spring-boot.formatted-version} → (v3.2.4)
// ${application.title} → Implementation-Title from MANIFEST.MF
// ${AnsiColor.BRIGHT_GREEN} → ANSI color codes (see below)
// ${AnsiColor.DEFAULT} → reset to default color
// Practical banner.txt with version info:
// ================================================
// MY APPLICATION
// Version : ${application.formatted-version}
// Spring Boot : ${spring-boot.formatted-version}
// Java : ${java.version}
// ================================================ASCII Art Banner
ASCII art banners are generated from text using online tools. This example shows a complete banner.txt with color, version info, and styled ASCII art.
Java
// src/main/resources/banner.txt
// (copy this content directly into the file — no Java code)
// ============================================================
// Example banner with ASCII art, colors, and version info:
${AnsiColor.BRIGHT_CYAN}
███╗ ███╗██╗ ██╗ █████╗ ██████╗ ██████╗
████╗ ████║╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗
██╔████╔██║ ╚████╔╝ ███████║██████╔╝██████╔╝
██║╚██╔╝██║ ╚██╔╝ ██╔══██║██╔═══╝ ██╔═══╝
██║ ╚═╝ ██║ ██║ ██║ ██║██║ ██║
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝
${AnsiColor.DEFAULT}
${AnsiColor.BRIGHT_WHITE} :: My Application ::${AnsiColor.DEFAULT}
${AnsiStyle.BOLD} Version :${AnsiStyle.NORMAL} ${application.formatted-version}
${AnsiStyle.BOLD} Spring Boot :${AnsiStyle.NORMAL} ${spring-boot.formatted-version}
${AnsiStyle.BOLD} Java :${AnsiStyle.NORMAL} ${java.version}
${AnsiStyle.BOLD} Profile :${AnsiStyle.NORMAL} ${spring.profiles.active}
// ============================================================
// Available ANSI colors:
// ${AnsiColor.BLACK} ${AnsiColor.BRIGHT_BLACK}
// ${AnsiColor.RED} ${AnsiColor.BRIGHT_RED}
// ${AnsiColor.GREEN} ${AnsiColor.BRIGHT_GREEN}
// ${AnsiColor.YELLOW} ${AnsiColor.BRIGHT_YELLOW}
// ${AnsiColor.BLUE} ${AnsiColor.BRIGHT_BLUE}
// ${AnsiColor.MAGENTA} ${AnsiColor.BRIGHT_MAGENTA}
// ${AnsiColor.CYAN} ${AnsiColor.BRIGHT_CYAN}
// ${AnsiColor.WHITE} ${AnsiColor.BRIGHT_WHITE}
// ${AnsiColor.DEFAULT} (reset to default)
// Available ANSI background colors:
// ${AnsiBackground.BLACK} ${AnsiBackground.RED} etc.
// Available ANSI styles:
// ${AnsiStyle.BOLD} ${AnsiStyle.NORMAL}
// ${AnsiStyle.ITALIC} ${AnsiStyle.UNDERLINE}
// ${AnsiStyle.FAINT}
// Note: ANSI codes only render in terminals that support them.
// CI/CD logs, log files, and Windows CMD may show escape characters.
// Set spring.output.ansi.enabled=DETECT to auto-detect terminal support.Image Banner — banner.gif / banner.jpg / banner.png
Spring Boot can convert an image file to ASCII art and print it as the banner. Place an image file named banner.gif, banner.jpg, or banner.png in src/main/resources.
Java
// Place in src/main/resources/:
// banner.gif — animated or static GIF
// banner.jpg — JPEG image
// banner.png — PNG image
// Spring Boot converts the image to ASCII art using character density mapping
// The image is resized to fit the terminal width automatically
// Configure the image banner:
# application.properties:
spring.banner.image.location=classpath:banner.png # explicit location
spring.banner.image.width=76 # ASCII art width in characters (default: 76)
spring.banner.image.height=0 # 0 = maintain aspect ratio (default: 0)
spring.banner.image.margin=2 # left margin (default: 2)
spring.banner.image.invert=false # invert colors for dark backgrounds
// Best practices for image banners:
// - Use simple, high-contrast logos or icons
// - Black and white images produce the cleanest ASCII output
// - Keep the source image small (64x64 to 128x128 pixels)
// - Test in your actual terminal before committing
// - Image banners are noticeably larger in log output than text banners
// You can have both banner.txt and a banner image:
// Spring Boot uses banner.txt if present, falls back to image, then default
// To explicitly choose:
# application.properties:
spring.banner.location=classpath:banner.txt # force text banner
spring.banner.image.location=classpath:logo.png # image banner pathControlling the Banner with Properties
Banner behavior is controlled through application.properties — when it is shown, where its output goes, and whether ANSI colors are enabled.
application.properties
# ── Banner mode ──────────────────────────────────────────────────────
# console — print to System.out (default):
spring.main.banner-mode=console
# log — write to the log file (via SLF4J logger):
spring.main.banner-mode=log
# off — disable banner entirely:
spring.main.banner-mode=off
# ── ANSI color support ────────────────────────────────────────────────
# DETECT — enable ANSI colors only if terminal supports them (default):
spring.output.ansi.enabled=DETECT
# ALWAYS — always output ANSI escape sequences:
spring.output.ansi.enabled=ALWAYS
# NEVER — never output ANSI escape sequences (clean log files):
spring.output.ansi.enabled=NEVER
# ── Banner location ───────────────────────────────────────────────────
# Custom text banner location (default: classpath:banner.txt):
spring.banner.location=classpath:banner.txt
spring.banner.location=classpath:banners/my-banner.txt
spring.banner.location=file:./banner.txt # from filesystem
# Custom image banner location:
spring.banner.image.location=classpath:logo.png
spring.banner.image.width=76
spring.banner.image.height=0
spring.banner.image.margin=2
spring.banner.image.invert=false
# ── Profile-specific banner control ──────────────────────────────────
# application-dev.properties:
spring.main.banner-mode=console # show banner in development
spring.output.ansi.enabled=ALWAYS
# application-prod.properties:
spring.main.banner-mode=log # log banner in production (for startup records)
spring.output.ansi.enabled=NEVER # no ANSI codes in production logs
# application-test.properties:
spring.main.banner-mode=off # no banner during testsProgrammatic Banner Customization
For full control — dynamic content, runtime environment data, conditional display — implement the Banner interface and register it with SpringApplication.
Java
// Custom Banner implementation:
public class ApplicationBanner implements Banner {
private static final String BANNER_TEXT = """
_ \s
| | \s
| |__ __ _ _ __ _ __ ___ _ __
| '_ \\ / _` | '_ \\| '_ \\ / _ \\ '__|
| |_) | (_| | | | | | | | __/ | \s
|_.__/ \\__,_|_| |_|_| |_|\\___|_| \s
""";
@Override
public void printBanner(Environment environment,
Class<?> sourceClass,
PrintStream printStream) {
// Print the ASCII art:
printStream.println(BANNER_TEXT);
// Print dynamic runtime information:
String appName = environment.getProperty("spring.application.name", "MyApp");
String version = environment.getProperty("app.version", "unknown");
String[] activeProfiles = environment.getActiveProfiles();
String profiles = activeProfiles.length > 0
? String.join(", ", activeProfiles)
: "default";
printStream.printf(" Application : %s%n", appName);
printStream.printf(" Version : %s%n", version);
printStream.printf(" Profile(s) : %s%n", profiles);
printStream.printf(" Java : %s%n", System.getProperty("java.version"));
printStream.printf(" PID : %s%n", ProcessHandle.current().pid());
printStream.printf(" Started at : %s%n", LocalDateTime.now());
printStream.println(" ─────────────────────────────────────────");
}
}
// Register with SpringApplication:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(Application.class);
app.setBanner(new ApplicationBanner());
app.run(args);
}
}
// Output example:
// _ \s
// | | \s
// | |__ __ _ _ __ _ __ ___ _ __
// | '_ \\ / _` | '_ \\| '_ \\ / _ \\ '__|
// | |_) | (_| | | | | | | | __/ | \s
// |_.__/ \\__,_|_| |_|_| |_|\\___|_| \s
//
// Application : MyApplication
// Version : 2.1.0
// Profile(s) : prod
// Java : 21.0.2
// PID : 45823
// Started at : 2024-01-15T10:30:00
// ─────────────────────────────────────────Banner Best Practices
Guidelines for banner configuration in different environments and team setups.
Java
// ── DEVELOPMENT ──────────────────────────────────────────────────────
// Keep the banner — it shows which service started and its version:
// application-dev.properties:
// spring.main.banner-mode=console
// spring.output.ansi.enabled=ALWAYS
// Add version and profile to banner.txt so you always know what's running:
// :: My Application :: ${application.formatted-version}
// Profile: ${spring.profiles.active:default}
// Spring Boot: ${spring-boot.formatted-version}
// ── PRODUCTION ────────────────────────────────────────────────────────
// Use log mode — banner appears in startup logs for audit purposes:
// application-prod.properties:
// spring.main.banner-mode=log
// spring.output.ansi.enabled=NEVER # no ANSI codes in log files
// The banner appears in logs as:
// INFO --- [main] o.s.b.SpringApplication : \n\n [banner content] \n\n
// ── TESTING ───────────────────────────────────────────────────────────
// Disable banner in tests — reduces test output noise:
// application-test.properties:
// spring.main.banner-mode=off
// Or globally in @SpringBootTest:
@SpringBootTest(properties = "spring.main.banner-mode=off")
class MyTest { }
// ── CI/CD PIPELINES ────────────────────────────────────────────────────
// Disable ANSI colors — CI logs don't render escape sequences:
// Environment variable in pipeline:
// SPRING_OUTPUT_ANSI_ENABLED=NEVER
// ── MAKING THE VERSION AVAILABLE in banner.txt ─────────────────────────
// ${application.version} reads from META-INF/MANIFEST.MF
// Spring Boot Maven plugin adds the version automatically:
// mvn package → META-INF/MANIFEST.MF contains:
// Implementation-Version: 1.0.0-SNAPSHOT
// Implementation-Title: myapp
// Verify: jar tf target/myapp.jar | grep MANIFEST
// unzip -p target/myapp.jar META-INF/MANIFEST.MF
// For Gradle — add to build.gradle:
// springBoot {
// buildInfo() // creates build-info.properties with version, time, etc.
// }
// Then use: ${build.version} in banner.txt