From: Duarte Meneses Date: Mon, 14 Dec 2020 22:15:20 +0000 (-0600) Subject: SONAR-12786 Improve startup error message when the TCP port is already taken X-Git-Tag: 8.7.0.41497~160 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=80c2a910e268532d42511d580c695a7b281054df;p=sonarqube.git SONAR-12786 Improve startup error message when the TCP port is already taken --- diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/app/EmbeddedTomcat.java b/server/sonar-webserver/src/main/java/org/sonar/server/app/EmbeddedTomcat.java index d0b0d4f74d0..e7bdc1d237f 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/app/EmbeddedTomcat.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/app/EmbeddedTomcat.java @@ -19,12 +19,15 @@ */ package org.sonar.server.app; +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; import com.google.common.base.Throwables; import java.io.File; import java.util.concurrent.CountDownLatch; import org.apache.catalina.LifecycleException; import org.apache.catalina.core.StandardContext; import org.apache.catalina.startup.Tomcat; +import org.slf4j.LoggerFactory; import org.sonar.api.utils.log.Loggers; import org.sonar.process.Props; @@ -63,7 +66,11 @@ class EmbeddedTomcat { TomcatConnectors.configure(tomcat, props); webappContext = new TomcatContexts().configure(tomcat, props); try { + // let Tomcat temporarily log errors at start up - for example, port in use + Logger logger = (Logger) LoggerFactory.getLogger("org.apache.catalina.core.StandardService"); + logger.setLevel(Level.ERROR); tomcat.start(); + logger.setLevel(Level.OFF); new TomcatStartupLogs(Loggers.get(getClass())).log(tomcat); } catch (LifecycleException e) { Loggers.get(EmbeddedTomcat.class).error("Fail to start web server", e);