diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-07-17 18:50:33 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-07-17 18:50:42 +0200 |
commit | d3d7f253ecd6bb7cfa61e1e8d8fce10a7371e096 (patch) | |
tree | 24833f50d514650e6dd24a0b7fc9c48648034f6c | |
parent | 6e54f5c0324812617a962c1835e7710022488985 (diff) | |
download | sonarqube-d3d7f253ecd6bb7cfa61e1e8d8fce10a7371e096.tar.gz sonarqube-d3d7f253ecd6bb7cfa61e1e8d8fce10a7371e096.zip |
Fix sonar.showSql
3 files changed, 26 insertions, 44 deletions
diff --git a/sonar-batch/src/main/resources/org/sonar/batch/bootstrapper/logback.xml b/sonar-batch/src/main/resources/org/sonar/batch/bootstrapper/logback.xml index 12a7e1db673..eb3084afa54 100644 --- a/sonar-batch/src/main/resources/org/sonar/batch/bootstrapper/logback.xml +++ b/sonar-batch/src/main/resources/org/sonar/batch/bootstrapper/logback.xml @@ -39,13 +39,22 @@ </logger> <!-- sonar.showSql --> + <!-- see also org.sonar.core.persistence.MyBatis#configureLogback() --> <logger name="org.hibernate.SQL"> <level value="${SQL_LOGGER_LEVEL:-ERROR}"/> </logger> <logger name="org.mybatis"> - <level value="${SQL_LOGGER_LEVEL:-WARN}"/> - </logger> - <!-- see also org.sonar.core.persistence.MyBatis#configureLogback() --> + <level value="${SQL_LOGGER_LEVEL:-WARN}"/> + </logger> + <logger name="org.apache.ibatis"> + <level value="${SQL_LOGGER_LEVEL:-WARN}"/> + </logger> + <logger name="java.sql"> + <level value="${SQL_LOGGER_LEVEL:-WARN}"/> + </logger> + <logger name="java.sql.ResultSet"> + <level value="${SQL_RESULTS_LOGGER_LEVEL:-WARN}"/> + </logger> <root> <!-- sonar.verbose --> diff --git a/sonar-batch/src/main/resources/org/sonar/batch/logback.xml b/sonar-batch/src/main/resources/org/sonar/batch/logback.xml index 4171dcb6e34..1dba6b7f3cc 100644 --- a/sonar-batch/src/main/resources/org/sonar/batch/logback.xml +++ b/sonar-batch/src/main/resources/org/sonar/batch/logback.xml @@ -35,6 +35,7 @@ </logger> <!-- sonar.showSql --> + <!-- see also org.sonar.core.persistence.MyBatis#configureLogback() --> <logger name="org.hibernate.SQL"> <level value="${SQL_LOGGER_LEVEL:-ERROR}"/> </logger> @@ -42,8 +43,8 @@ <level value="${SQL_LOGGER_LEVEL:-WARN}"/> </logger> <logger name="org.mybatis"> - <level value="${SQL_LOGGER_LEVEL:-WARN}"/> - </logger> + <level value="${SQL_LOGGER_LEVEL:-WARN}"/> + </logger> <logger name="java.sql"> <level value="${SQL_LOGGER_LEVEL:-WARN}"/> </logger> diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java index e6a62e55356..cfb7b9c0859 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java @@ -19,57 +19,35 @@ */ package org.sonar.core.persistence; -import org.sonar.api.database.model.MeasureData; - import ch.qos.logback.classic.Level; import com.google.common.io.Closeables; import org.apache.ibatis.builder.xml.XMLMapperBuilder; import org.apache.ibatis.logging.LogFactory; import org.apache.ibatis.mapping.Environment; -import org.apache.ibatis.session.Configuration; -import org.apache.ibatis.session.ExecutorType; -import org.apache.ibatis.session.SqlSession; -import org.apache.ibatis.session.SqlSessionFactory; -import org.apache.ibatis.session.SqlSessionFactoryBuilder; +import org.apache.ibatis.session.*; import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory; import org.apache.ibatis.type.JdbcType; import org.slf4j.LoggerFactory; import org.sonar.api.BatchComponent; import org.sonar.api.ServerComponent; import org.sonar.api.config.Settings; +import org.sonar.api.database.model.MeasureData; import org.sonar.api.database.model.MeasureMapper; import org.sonar.api.database.model.MeasureModel; import org.sonar.core.config.Logback; -import org.sonar.core.dashboard.ActiveDashboardDto; -import org.sonar.core.dashboard.ActiveDashboardMapper; -import org.sonar.core.dashboard.DashboardDto; -import org.sonar.core.dashboard.DashboardMapper; -import org.sonar.core.dashboard.WidgetDto; -import org.sonar.core.dashboard.WidgetMapper; -import org.sonar.core.dashboard.WidgetPropertyDto; -import org.sonar.core.dashboard.WidgetPropertyMapper; +import org.sonar.core.dashboard.*; import org.sonar.core.dependency.DependencyDto; import org.sonar.core.dependency.DependencyMapper; import org.sonar.core.dependency.ResourceSnapshotDto; import org.sonar.core.dependency.ResourceSnapshotMapper; import org.sonar.core.duplication.DuplicationMapper; import org.sonar.core.duplication.DuplicationUnitDto; -import org.sonar.core.filter.CriterionDto; -import org.sonar.core.filter.CriterionMapper; -import org.sonar.core.filter.FilterColumnDto; -import org.sonar.core.filter.FilterColumnMapper; -import org.sonar.core.filter.FilterDto; -import org.sonar.core.filter.FilterMapper; +import org.sonar.core.filter.*; import org.sonar.core.properties.PropertiesMapper; import org.sonar.core.properties.PropertyDto; import org.sonar.core.purge.PurgeMapper; import org.sonar.core.purge.PurgeableSnapshotDto; -import org.sonar.core.resource.ResourceDto; -import org.sonar.core.resource.ResourceIndexDto; -import org.sonar.core.resource.ResourceIndexerMapper; -import org.sonar.core.resource.ResourceKeyUpdaterMapper; -import org.sonar.core.resource.ResourceMapper; -import org.sonar.core.resource.SnapshotDto; +import org.sonar.core.resource.*; import org.sonar.core.review.ReviewCommentDto; import org.sonar.core.review.ReviewCommentMapper; import org.sonar.core.review.ReviewDto; @@ -78,14 +56,7 @@ import org.sonar.core.rule.RuleDto; import org.sonar.core.rule.RuleMapper; import org.sonar.core.template.LoadedTemplateDto; import org.sonar.core.template.LoadedTemplateMapper; -import org.sonar.core.user.AuthorDto; -import org.sonar.core.user.AuthorMapper; -import org.sonar.core.user.GroupDto; -import org.sonar.core.user.GroupRoleDto; -import org.sonar.core.user.RoleMapper; -import org.sonar.core.user.UserDto; -import org.sonar.core.user.UserMapper; -import org.sonar.core.user.UserRoleDto; +import org.sonar.core.user.*; import java.io.InputStream; @@ -188,11 +159,12 @@ public class MyBatis implements BatchComponent, ServerComponent { * See http://www.mybatis.org/core/logging.html : */ private void configureLogback(Class<?>... mapperClasses) { + Level level = Level.INFO; if (settings.getBoolean("sonar.showSql")) { - Level level = (settings.getBoolean("sonar.showSqlResults") ? Level.TRACE : Level.DEBUG); - for (Class mapperClass : mapperClasses) { - logback.setLoggerLevel(mapperClass.getName(), level); - } + level = settings.getBoolean("sonar.showSqlResults") ? Level.TRACE : Level.DEBUG; + } + for (Class mapperClass : mapperClasses) { + logback.setLoggerLevel(mapperClass.getName(), level); } } |