You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by ls...@apache.org on 2015/11/14 08:15:43 UTC
incubator-sentry git commit: SENTRY-945: Avoid logging all
DataNucleus queries when debug logging is enabled (Li Li via Lenni Kuff)
Repository: incubator-sentry
Updated Branches:
refs/heads/master f0b936751 -> e6e7d7311
SENTRY-945: Avoid logging all DataNucleus queries when debug logging is enabled (Li Li via Lenni Kuff)
Change-Id: I5b9fc7f266f05456387980e9c6c734d30a5dca7c
Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/e6e7d731
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/e6e7d731
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/e6e7d731
Branch: refs/heads/master
Commit: e6e7d7311174c83c02b5074a0d959b3326f8223c
Parents: f0b9367
Author: Lenni Kuff <ls...@cloudera.com>
Authored: Fri Nov 13 23:14:18 2015 -0800
Committer: Lenni Kuff <ls...@cloudera.com>
Committed: Fri Nov 13 23:14:18 2015 -0800
----------------------------------------------------------------------
.../main/java/org/apache/sentry/SentryMain.java | 22 +++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/e6e7d731/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/SentryMain.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/SentryMain.java b/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/SentryMain.java
index 7b1b6ac..e081a86 100644
--- a/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/SentryMain.java
+++ b/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/SentryMain.java
@@ -27,6 +27,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableMap;
+import java.io.FileInputStream;
+import java.util.Properties;
public class SentryMain {
private static final String HELP_SHORT = "h";
@@ -58,7 +60,25 @@ public class SentryMain {
String log4jconf = commandLine.getOptionValue(LOG4J_CONF);
if ((log4jconf != null)&&(log4jconf.length() > 0)) {
- PropertyConfigurator.configure(log4jconf);
+ Properties log4jProperties = new Properties();
+
+ // Firstly load log properties from properties file
+ FileInputStream istream = new FileInputStream(log4jconf);
+ log4jProperties.load(istream);
+ istream.close();
+
+ // Set the log level of DataNucleus.Query to INFO only if it is not set in the
+ // properties file
+ if (!log4jProperties.containsKey("log4j.category.DataNucleus.Query")) {
+ log4jProperties.setProperty("log4j.category.DataNucleus.Query", "INFO");
+
+ // Enable debug log for DataNucleus.Query only when log.threshold is TRACE
+ if (log4jProperties.getProperty("log.threshold").equalsIgnoreCase("TRACE")) {
+ log4jProperties.setProperty("log4j.category.DataNucleus.Query", "DEBUG");
+ }
+ }
+
+ PropertyConfigurator.configure(log4jProperties);
Logger sentryLogger = LoggerFactory.getLogger(SentryMain.class);
sentryLogger.info("Configuring log4j to use [" + log4jconf + "]");
}