summaryrefslogtreecommitdiffstats
path: root/sonar-maven-plugin
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-maven-plugin')
-rw-r--r--sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java25
-rw-r--r--sonar-maven-plugin/src/main/resources/org/sonar/maven/logback.xml42
2 files changed, 15 insertions, 52 deletions
diff --git a/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java b/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
index 7a7ae79d438..9c3a42309ec 100644
--- a/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
+++ b/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
@@ -38,7 +38,7 @@ import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.batch.Batch;
import org.sonar.batch.MavenProjectConverter;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
-import org.sonar.core.config.Logback;
+import org.sonar.batch.bootstrapper.LoggingConfiguration;
/**
* @goal sonar
@@ -137,8 +137,13 @@ public final class SonarMojo extends AbstractMojo {
*/
private boolean verbose;
+ /**
+ * @parameter expression="${sonar.showSql}" default-value="false"
+ */
+ private boolean showSql;
+
public void execute() throws MojoExecutionException, MojoFailureException {
- configureLogback();
+ configureLogging();
executeBatch();
}
@@ -147,8 +152,8 @@ public final class SonarMojo extends AbstractMojo {
ProjectReactor reactor = new ProjectReactor(def);
Batch batch = new Batch(reactor, session, getLog(), lifecycleExecutor, pluginManager, artifactFactory,
- localRepository, artifactMetadataSource, artifactCollector, dependencyTreeBuilder,
- projectBuilder, getEnvironmentInformation(), Maven2PluginExecutor.class);
+ localRepository, artifactMetadataSource, artifactCollector, dependencyTreeBuilder,
+ projectBuilder, getEnvironmentInformation(), Maven2PluginExecutor.class);
batch.execute();
}
@@ -157,11 +162,11 @@ public final class SonarMojo extends AbstractMojo {
return new EnvironmentInformation("Maven", mavenVersion);
}
- private void configureLogback() {
- boolean debugMode = (verbose || getLog().isDebugEnabled());
-
- // this system property is required by the logback configuration
- System.setProperty("ROOT_LOGGER_LEVEL", debugMode ? "DEBUG" : "INFO");
- Logback.configure("/org/sonar/maven/logback.xml");
+ private void configureLogging() {
+ LoggingConfiguration.create()
+ .setVerbose(verbose || getLog().isDebugEnabled())
+ .setShowSql(showSql)
+ .setFormat(LoggingConfiguration.FORMAT_MAVEN)
+ .configure();
}
}
diff --git a/sonar-maven-plugin/src/main/resources/org/sonar/maven/logback.xml b/sonar-maven-plugin/src/main/resources/org/sonar/maven/logback.xml
deleted file mode 100644
index 5d6bf58530e..00000000000
--- a/sonar-maven-plugin/src/main/resources/org/sonar/maven/logback.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<configuration debug="false">
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>[%level] [%d{HH:mm:ss.SSS}] %msg%n</pattern>
- </encoder>
- </appender>
-
- <logger name="org.hibernate">
- <level value="WARN"/>
- </logger>
-
- <!-- set DEBUG to activate SQL logs. NOT RECOMMENDED -->
- <logger name="org.hibernate.SQL">
- <level value="ERROR"/>
- </logger>
-
- <!-- BeanUtils generate to many DEBUG logs when sonar.verbose is set -->
- <logger name="org.apache.commons.beanutils.converters">
- <level value="WARN"/>
- </logger>
-
- <logger name="net.sf.ehcache">
- <level value="WARN"/>
- </logger>
-
- <logger name="org.hibernate.cache.ReadWriteCache">
- <!-- removing "An item was expired by the cache while it was locked (increase your cache timeout)" msg -->
- <level value="ERROR"/>
- </logger>
- <logger name="org.hibernate.cache.EhCacheProvider">
- <!-- removing "org.hibernate.cache.EhCacheProvider - Could not find configuratio)" message -->
- <level value="ERROR"/>
- </logger>
-
- <root>
- <level value="${ROOT_LOGGER_LEVEL}"/>
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration> \ No newline at end of file