sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hshreedha...@apache.org
Subject sqoop git commit: SQOOP-2598. Sqoop2: Main sqoop.log is missing log outputs from classes other then org.apache.sqoop
Date Fri, 09 Oct 2015 06:30:50 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 d82e9d302 -> 2a9e8d994


SQOOP-2598. Sqoop2: Main sqoop.log is missing log outputs from classes other then org.apache.sqoop

(Jarcec via Hari)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/2a9e8d99
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/2a9e8d99
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/2a9e8d99

Branch: refs/heads/sqoop2
Commit: 2a9e8d99481cf2c2de4b2ce91e5b98f3935e49a6
Parents: d82e9d3
Author: Hari Shreedharan <hshreedharan@apache.org>
Authored: Thu Oct 8 23:29:57 2015 -0700
Committer: Hari Shreedharan <hshreedharan@apache.org>
Committed: Thu Oct 8 23:29:57 2015 -0700

----------------------------------------------------------------------
 .../sqoop/error/code/AuditLoggerError.java      |  4 +--
 .../org/apache/sqoop/audit/FileAuditLogger.java | 27 +++++---------------
 dist/src/main/conf/sqoop.properties             | 19 +++++++++-----
 .../test/minicluster/SqoopMiniCluster.java      |  6 ++---
 4 files changed, 23 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/2a9e8d99/common/src/main/java/org/apache/sqoop/error/code/AuditLoggerError.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/error/code/AuditLoggerError.java b/common/src/main/java/org/apache/sqoop/error/code/AuditLoggerError.java
index 1af8d7d..87de7d1 100644
--- a/common/src/main/java/org/apache/sqoop/error/code/AuditLoggerError.java
+++ b/common/src/main/java/org/apache/sqoop/error/code/AuditLoggerError.java
@@ -27,8 +27,8 @@ public enum AuditLoggerError implements ErrorCode {
   /** The system was unable to find or load the audit logger provider. */
   AUDIT_0001("The system was unable to find or load audit logger class"),
 
-  /** The audit logger output file is not given. */
-  AUDIT_0002("The output file for FileAuditLogger is not given"),
+  /** The audit logger name is not given. */
+  AUDIT_0002("The logger name for FileAuditLogger is not specified"),
 
   ;
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/2a9e8d99/core/src/main/java/org/apache/sqoop/audit/FileAuditLogger.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/audit/FileAuditLogger.java b/core/src/main/java/org/apache/sqoop/audit/FileAuditLogger.java
index 49a380c..8ae3aa3 100644
--- a/core/src/main/java/org/apache/sqoop/audit/FileAuditLogger.java
+++ b/core/src/main/java/org/apache/sqoop/audit/FileAuditLogger.java
@@ -18,10 +18,8 @@
 package org.apache.sqoop.audit;
 
 import java.util.Map;
-import java.util.Properties;
 
 import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.error.code.AuditLoggerError;
 
@@ -29,12 +27,10 @@ public class FileAuditLogger extends AuditLogger {
 
   private Logger LOG = Logger.getLogger(FileAuditLogger.class);
 
-  private static final String APPENDER_SURFIX = "Appender";
-
   /**
    * The option name for audit log file location
    */
-  private static final String FILE = "file";
+  private static final String LOGGER = "logger";
 
   /**
    * The logger for output log lines
@@ -46,27 +42,16 @@ public class FileAuditLogger extends AuditLogger {
   public void initialize() {
     Map<String, String> config = getLoggerConfig();
 
-    String outputFile = config.get(FILE);
-    if (outputFile == null) {
+    String loggerName = config.get(LOGGER);
+    if (loggerName == null) {
       throw new SqoopException(AuditLoggerError.AUDIT_0002);
     }
 
-    // setup logger
-    String appender = "log4j.appender." + getLoggerName() + APPENDER_SURFIX;
-    LOG.warn("appender: " + appender);
-    Properties props = new Properties();
-    props.put(appender, "org.apache.log4j.RollingFileAppender");
-    props.put(appender + ".File", outputFile);
-    props.put(appender + ".layout", "org.apache.log4j.PatternLayout");
-    props.put(appender + ".layout.ConversionPattern", "%d %-5p %c: %m%n");
-    props.put("log4j.logger." + getLoggerName(), "INFO," + getLoggerName() + APPENDER_SURFIX);
-    PropertyConfigurator.configure(props);
-
-    logger = Logger.getLogger(getLoggerName());
+    LOG.debug("Using audit logger name: " + loggerName);
+    logger = Logger.getLogger(loggerName);
   }
 
-  public void logAuditEvent(String username, String ip, String operation, String objectType,
-          String objectId) {
+  public void logAuditEvent(String username, String ip, String operation, String objectType,
String objectId) {
     StringBuilder sentence = new StringBuilder();
     sentence.append("user=").append(username).append("\t");
     sentence.append("ip=").append(ip).append("\t");

http://git-wip-us.apache.org/repos/asf/sqoop/blob/2a9e8d99/dist/src/main/conf/sqoop.properties
----------------------------------------------------------------------
diff --git a/dist/src/main/conf/sqoop.properties b/dist/src/main/conf/sqoop.properties
index f077ecc..7ef62b4 100755
--- a/dist/src/main/conf/sqoop.properties
+++ b/dist/src/main/conf/sqoop.properties
@@ -45,16 +45,23 @@
 # to specify log4j configuration properties from within the
 # Sqoop configuration.
 #
+org.apache.sqoop.log4j.debug=false
+org.apache.sqoop.log4j.rootLogger=INFO, file
+org.apache.sqoop.log4j.category.org.apache.sqoop=INFO
 org.apache.sqoop.log4j.appender.file=org.apache.log4j.RollingFileAppender
 org.apache.sqoop.log4j.appender.file.File=@LOGDIR@/sqoop.log
 org.apache.sqoop.log4j.appender.file.MaxFileSize=25MB
 org.apache.sqoop.log4j.appender.file.MaxBackupIndex=5
 org.apache.sqoop.log4j.appender.file.layout=org.apache.log4j.PatternLayout
-org.apache.sqoop.log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} [%l]
%m%n
-org.apache.sqoop.log4j.debug=false
-org.apache.sqoop.log4j.rootCategory=WARN, file
-org.apache.sqoop.log4j.category.org.apache.sqoop=DEBUG
-org.apache.sqoop.log4j.category.org.apache.derby=INFO
+org.apache.sqoop.log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %-5p [%l] %m%n
+# Audit logger for default configuration of FileAuditLogger
+org.apache.sqoop.log4j.logger.audit=INFO, audit
+org.apache.sqoop.log4j.appender.audit=org.apache.log4j.RollingFileAppender
+org.apache.sqoop.log4j.appender.audit.File=@LOGDIR@/audit.log
+org.apache.sqoop.log4j.appender.audit.MaxFileSize=25MB
+org.apache.sqoop.log4j.appender.audit.MaxBackupIndex=5
+org.apache.sqoop.log4j.appender.audit.layout=org.apache.log4j.PatternLayout
+org.apache.sqoop.log4j.appender.audit.layout.ConversionPattern=%d{ISO8601} %-5p [%l] %m%n
 
 #
 # Audit Loggers Configuration
@@ -66,7 +73,7 @@ org.apache.sqoop.log4j.category.org.apache.derby=INFO
 # are parsed to the logger class.
 #
 org.apache.sqoop.auditlogger.default.class=org.apache.sqoop.audit.FileAuditLogger
-org.apache.sqoop.auditlogger.default.file=@LOGDIR@/default.audit
+org.apache.sqoop.auditlogger.default.logger=audit
 
 #
 # Repository configuration

http://git-wip-us.apache.org/repos/asf/sqoop/blob/2a9e8d99/test/src/main/java/org/apache/sqoop/test/minicluster/SqoopMiniCluster.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/minicluster/SqoopMiniCluster.java b/test/src/main/java/org/apache/sqoop/test/minicluster/SqoopMiniCluster.java
index 328c053..8a0faf8 100644
--- a/test/src/main/java/org/apache/sqoop/test/minicluster/SqoopMiniCluster.java
+++ b/test/src/main/java/org/apache/sqoop/test/minicluster/SqoopMiniCluster.java
@@ -167,11 +167,9 @@ public abstract class SqoopMiniCluster {
 
     properties.put("org.apache.sqoop.log4j.appender.file", "org.apache.log4j.ConsoleAppender");
     properties.put("org.apache.sqoop.log4j.appender.file.layout", "org.apache.log4j.PatternLayout");
-    properties.put("org.apache.sqoop.log4j.appender.file.layout.ConversionPattern", "%d{ISO8601}
%-5p %c{2} [%l] %m%n");
+    properties.put("org.apache.sqoop.log4j.appender.file.layout.ConversionPattern", "%d{ISO8601}
%-5p [%l] %m%n");
     properties.put("org.apache.sqoop.log4j.debug", "true");
-    properties.put("org.apache.sqoop.log4j.rootCategory", "WARN, file");
-    properties.put("org.apache.sqoop.log4j.category.org.apache.sqoop", "DEBUG");
-    properties.put("org.apache.sqoop.log4j.category.org.apache.derby", "INFO");
+    properties.put("org.apache.sqoop.log4j.rootCategory", "DEBUG, file");
 
     return properties;
   }


Mime
View raw message