@@ -28,12 +28,14 @@ class Webapp { | |||
private static final String JRUBY_MAX_RUNTIMES = "jruby.max.runtimes"; | |||
private static final String RAILS_ENV = "rails.env"; | |||
private static final String PROPERTY_CONTEXT = "sonar.web.context"; | |||
private static final String PROPERTY_LOG_VERBOSE = "sonar.log.verbose"; | |||
static void configure(Tomcat tomcat, Env env, Props props) { | |||
String ctx = getContext(props); | |||
try { | |||
Context context = tomcat.addWebapp(ctx, env.file("web").getAbsolutePath()); | |||
context.setConfigFile(env.file("web/META-INF/context.xml").toURI().toURL()); | |||
context.addParameter(PROPERTY_LOG_VERBOSE, props.of(PROPERTY_LOG_VERBOSE, "false")); | |||
configureRailsMode(props, context); | |||
context.setJarScanner(new NullJarScanner()); | |||
@@ -360,6 +360,7 @@ | |||
<sonar.runtime.mode>development</sonar.runtime.mode> | |||
<sonar.es.http.host>127.0.0.1</sonar.es.http.host> | |||
<sonar.es.http.port>9200</sonar.es.http.port> | |||
<sonar.log.verbose>true</sonar.log.verbose> | |||
<sonar.log.profilingLevel>FULL</sonar.log.profilingLevel> | |||
</systemProperties> | |||
</configuration> |
@@ -19,19 +19,20 @@ | |||
*/ | |||
package org.sonar.server.platform; | |||
import com.google.common.collect.ImmutableMap; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.core.config.Logback; | |||
import javax.servlet.ServletContextEvent; | |||
import javax.servlet.ServletContextListener; | |||
import java.io.File; | |||
import java.util.Collections; | |||
import java.util.Map; | |||
public final class PlatformLifecycleListener implements ServletContextListener { | |||
public void contextInitialized(ServletContextEvent event) { | |||
try { | |||
configureLogback(); | |||
configureLogback(event); | |||
Platform.getInstance().init(event.getServletContext()); | |||
Platform.getInstance().start(); | |||
} catch (Throwable t) { | |||
@@ -58,9 +59,11 @@ public final class PlatformLifecycleListener implements ServletContextListener { | |||
} | |||
/** | |||
* Configure Logback with $SONAR_HOME/conf/logback.xml | |||
* Configure Logback from classpath, with configuration from sonar.properties | |||
*/ | |||
private void configureLogback() { | |||
Logback.configure(new File(SonarHome.getHome(), "conf/logback.xml"), Collections.<String, String>emptyMap()); | |||
private void configureLogback(ServletContextEvent event) { | |||
boolean sonarLogVerbose = Boolean.valueOf(event.getServletContext().getInitParameter("sonar.log.verbose")); | |||
Map<String, String> variables = ImmutableMap.of("ROOT_LOGGER_LEVEL", sonarLogVerbose ? "DEBUG" : "INFO"); | |||
Logback.configure("/org/sonar/server/platform/logback.xml", variables); | |||
} | |||
} |
@@ -82,25 +82,9 @@ | |||
<logger name="org.elasticsearch.http"> | |||
<level value="INFO"/> | |||
</logger> | |||
<!-- ElasticSearch profiling information --> | |||
<!-- | |||
<logger name="org.sonar.server.search"> | |||
<level value="DEBUG"/> | |||
</logger> | |||
--> | |||
<!-- Export of dry run database --> | |||
<!-- | |||
<logger name="org.sonar.core.persistence.DbTemplate"> | |||
<level value="DEBUG"/> | |||
</logger> | |||
<logger name="org.sonar.core.persistence.DryRunDatabaseFactory"> | |||
<level value="DEBUG"/> | |||
</logger> | |||
--> | |||
<root> | |||
<level value="INFO"/> | |||
<level value="${ROOT_LOGGER_LEVEL}"/> | |||
<appender-ref ref="LOGFILE"/> | |||
</root> | |||