From: David Gageot Date: Wed, 7 Nov 2012 08:44:34 +0000 (+0100) Subject: SONAR-3866 Ignore "... JVM BUG(s) ..." logs generated by Jetty X-Git-Tag: 3.4~376 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ee471d514d370f5b336363cce711052dba03f88c;p=sonarqube.git SONAR-3866 Ignore "... JVM BUG(s) ..." logs generated by Jetty --- diff --git a/sonar-application/src/main/java/org/sonar/application/FilteredLogger.java b/sonar-application/src/main/java/org/sonar/application/FilteredLogger.java new file mode 100644 index 00000000000..41dbae338f9 --- /dev/null +++ b/sonar-application/src/main/java/org/sonar/application/FilteredLogger.java @@ -0,0 +1,75 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.application; + +import org.mortbay.log.Logger; +import org.mortbay.log.StdErrLog; + +public class FilteredLogger implements Logger { + private final String name; + private final Logger delegate; + + public FilteredLogger() { + this(null); + } + + private FilteredLogger(String name) { + this.name = name; + this.delegate = new StdErrLog(name); + } + + public boolean isDebugEnabled() { + return delegate.isDebugEnabled(); + } + + public void setDebugEnabled(boolean enabled) { + delegate.setDebugEnabled(enabled); + } + + public void info(String msg, Object arg0, Object arg1) { + if (msg.contains("JVM BUG(s)")) { + return; // Ignore, see SONAR-3866 + } + delegate.info(msg, arg0, arg1); + } + + public void debug(String msg, Throwable th) { + delegate.debug(msg, th); + } + + public void debug(String msg, Object arg0, Object arg1) { + delegate.debug(msg, arg0, arg1); + } + + public void warn(String msg, Object arg0, Object arg1) { + delegate.warn(msg, arg0, arg1); + } + + public void warn(String msg, Throwable th) { + delegate.warn(msg, th); + } + + public Logger getLogger(String name) { + if ((name == null && this.name == null) || ((name != null) && name.equals(this.name))) { + return this; + } + return new FilteredLogger(name); + } +} diff --git a/sonar-application/src/main/java/org/sonar/application/StartServer.java b/sonar-application/src/main/java/org/sonar/application/StartServer.java index 6d241327c42..68816d8237d 100644 --- a/sonar-application/src/main/java/org/sonar/application/StartServer.java +++ b/sonar-application/src/main/java/org/sonar/application/StartServer.java @@ -37,6 +37,7 @@ public final class StartServer { public static void main(String[] args) throws Exception { canCreateTemporaryFiles(); configureHome(); + configureJettyLogger(); Properties configuration = getConfiguration(); String host = configuration.getProperty("sonar.web.host", DEFAULT_WEB_HOST); @@ -81,4 +82,8 @@ public final class StartServer { System.setProperty("SONAR_HOME" /* see constant org.sonar.server.platform.SonarHome.PROPERTY */, confFile.getParentFile().getParentFile().getAbsolutePath()); } + + private static void configureJettyLogger() { + System.setProperty("org.mortbay.log.class", FilteredLogger.class.getName()); + } }