From 4fe1d1a206682fd09f3c6aa88a31137f90404564 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 17 Sep 2025 18:48:41 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E5=90=AF=E5=8A=A8=E6=97=B6=E5=9C=A8=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=BE=93=E5=87=BA=E4=B8=80=E8=A1=8C=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1512449046446080]服务器启动时在日志文件输出一行记录 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1512449046446080 --- .../listener/TomcatStartupListener.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/main/java/neatlogic/framework/listener/TomcatStartupListener.java diff --git a/src/main/java/neatlogic/framework/listener/TomcatStartupListener.java b/src/main/java/neatlogic/framework/listener/TomcatStartupListener.java new file mode 100644 index 000000000..1426c60db --- /dev/null +++ b/src/main/java/neatlogic/framework/listener/TomcatStartupListener.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.listener; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; + +@WebListener +public class TomcatStartupListener implements ServletContextListener { + + private final static Logger logger = LoggerFactory.getLogger(TomcatStartupListener.class); + + @Override + public void contextInitialized(ServletContextEvent sce) { + // 服务器启动时在日志文件输出一行记录 + String message = "服务器正在启动..."; + if (logger.isErrorEnabled()) { + logger.error(message); + } + if (logger.isWarnEnabled()) { + logger.warn(message); + } + if (logger.isInfoEnabled()) { + logger.info(message); + } + if (logger.isDebugEnabled()) { + logger.debug(message); + } + if (logger.isTraceEnabled()) { + logger.trace(message); + } + } +} -- Gitee