From c403118289e53379668ca7991d66ea34211c471e Mon Sep 17 00:00:00 2001 From: Rinjae Date: Wed, 1 Jul 2026 10:37:08 +0900 Subject: [PATCH] =?UTF-8?q?-=20StartupInfoPrinter=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=20=EC=B6=94=EA=B0=80=20-=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EC=8B=9C=EC=9E=91=20=EC=8B=9C=20=EB=B0=B0=EB=84=88?= =?UTF-8?q?=20=EC=B6=9C=EB=A0=A5=20-=20MessageCode=20=EC=B1=84=EB=84=90=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20@Deprecated=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EA=B8=B0=EB=B3=B8=EA=B0=92=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?-=20MessageCode=20=EC=8B=A0=EA=B7=9C=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9E=90=20=EC=B6=94=EA=B0=80=20-=20channel=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../portal/config/StartupInfoPrinter.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/java/com/eactive/apim/portal/config/StartupInfoPrinter.java diff --git a/src/main/java/com/eactive/apim/portal/config/StartupInfoPrinter.java b/src/main/java/com/eactive/apim/portal/config/StartupInfoPrinter.java new file mode 100644 index 0000000..7a2bc65 --- /dev/null +++ b/src/main/java/com/eactive/apim/portal/config/StartupInfoPrinter.java @@ -0,0 +1,51 @@ +package com.eactive.apim.portal.config; + +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.boot.system.ApplicationPid; +import org.springframework.context.ApplicationListener; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +/** + * Prints a startup banner to stdout once boot is complete. + * + *

Uses {@link System#out} directly (not a logger) so the info is shown even when + * the logback console appender is disabled (CONSOLE_LOG_ENABLED=false). + */ +@Component +public class StartupInfoPrinter implements ApplicationListener { + + @Override + public void onApplicationEvent(ApplicationReadyEvent event) { + Environment env = event.getApplicationContext().getEnvironment(); + + String port = env.getProperty("server.port", "8080"); + String contextPath = env.getProperty("server.servlet.context-path", "/"); + if (!contextPath.startsWith("/")) { + contextPath = "/" + contextPath; + } + String url = "http://localhost:" + port + contextPath; + + String[] active = env.getActiveProfiles(); + String profile = active.length == 0 + ? String.join(", ", env.getDefaultProfiles()) + : String.join(", ", active); + + String instanceName = env.getProperty("inst.Name", System.getProperty("inst.Name", "unknown")); + String pid = new ApplicationPid().toString(); + + StringBuilder sb = new StringBuilder(); + sb.append(System.lineSeparator()); + sb.append("=====================================================").append(System.lineSeparator()); + sb.append(" EAPIM Portal - startup complete").append(System.lineSeparator()); + sb.append("=====================================================").append(System.lineSeparator()); + sb.append(" URL : ").append(url).append(System.lineSeparator()); + sb.append(" Spring profile : ").append(profile).append(System.lineSeparator()); + sb.append(" Instance name : ").append(instanceName).append(System.lineSeparator()); + sb.append(" PID : ").append(pid).append(System.lineSeparator()); + sb.append("=====================================================").append(System.lineSeparator()); + + System.out.println(sb); + System.out.flush(); + } +}