]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3866 Ignore "... JVM BUG(s) ..." logs generated by Jetty
authorDavid Gageot <david@gageot.net>
Wed, 7 Nov 2012 08:44:34 +0000 (09:44 +0100)
committerDavid Gageot <david@gageot.net>
Wed, 7 Nov 2012 08:58:00 +0000 (09:58 +0100)
sonar-application/src/main/java/org/sonar/application/FilteredLogger.java [new file with mode: 0644]
sonar-application/src/main/java/org/sonar/application/StartServer.java

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 (file)
index 0000000..41dbae3
--- /dev/null
@@ -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);
+  }
+}
index 6d241327c42141a284866dbbc0c0052febe160d6..68816d8237dfecb1de7e56c7a8ce40812e6f6ae2 100644 (file)
@@ -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());
+  }
 }