You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2015/10/04 15:57:47 UTC

incubator-kylin git commit: KYLIN-457 Fix log4j error and dup lines in kylin.log

Repository: incubator-kylin
Updated Branches:
  refs/heads/2.x-staging 80fa2ebd8 -> 2ddaeabf1


KYLIN-457 Fix log4j error and dup lines in kylin.log


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

Branch: refs/heads/2.x-staging
Commit: 2ddaeabf15fa06a487671d48326ea4e434db86d3
Parents: 80fa2eb
Author: Yang Li <li...@apache.org>
Authored: Sun Oct 4 21:57:37 2015 +0800
Committer: Yang Li <li...@apache.org>
Committed: Sun Oct 4 21:57:37 2015 +0800

----------------------------------------------------------------------
 .../src/main/resources/kylin-log4j.properties   | 28 +++++++++++
 .../src/main/resources/kylinlog4j.properties    | 10 ----
 core-common/src/main/resources/log4j.properties | 10 ----
 jdbc/src/main/resources/log4j.properties        | 14 ------
 .../java/org/apache/kylin/rest/DebugTomcat.java |  2 +
 .../kylin/rest/util/Log4jConfigListener.java    | 46 ++++++++++++++++++
 .../resources/kylin-server-log4j.properties     | 51 ++++++++++++++++++++
 server/src/main/resources/log4j.properties      | 38 ---------------
 server/src/main/webapp/WEB-INF/web.xml          |  6 +--
 9 files changed, 130 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/2ddaeabf/core-common/src/main/resources/kylin-log4j.properties
----------------------------------------------------------------------
diff --git a/core-common/src/main/resources/kylin-log4j.properties b/core-common/src/main/resources/kylin-log4j.properties
new file mode 100644
index 0000000..b8816bd
--- /dev/null
+++ b/core-common/src/main/resources/kylin-log4j.properties
@@ -0,0 +1,28 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# enable this by -Dlog4j.configuration=kylin-log4j.properties
+
+log4j.rootLogger=INFO,stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=L4J [%d{yyyy-MM-dd HH:mm:ss,SSS}][%p][%c] - %m%n
+
+#log4j.logger.org.apache.hadoop=ERROR
+log4j.logger.org.apache.kylin=DEBUG
+log4j.logger.org.springframework=WARN

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/2ddaeabf/core-common/src/main/resources/kylinlog4j.properties
----------------------------------------------------------------------
diff --git a/core-common/src/main/resources/kylinlog4j.properties b/core-common/src/main/resources/kylinlog4j.properties
deleted file mode 100644
index 7c3f26a..0000000
--- a/core-common/src/main/resources/kylinlog4j.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-# use this when conflict with hbase, enable this by -Dlog4j.configuration=kylinlog4j.properties
-
-log4j.rootLogger=INFO,stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=L4J [%d{yyyy-MM-dd HH:mm:ss,SSS}][%p][%c] - %m%n
-
-#log4j.logger.org.apache.hadoop=ERROR
-log4j.logger.org.apache.kylin=DEBUG

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/2ddaeabf/core-common/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/core-common/src/main/resources/log4j.properties b/core-common/src/main/resources/log4j.properties
deleted file mode 100644
index 65f2f68..0000000
--- a/core-common/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-
-log4j.rootLogger=INFO,stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=L4J [%d{HH:mm:ss,SSS}][%t][%p][%C{1}] - %m%n
-
-#log4j.logger.org.apache.hadoop=ERROR
-log4j.logger.org.apache.kylin=DEBUG
-log4j.logger.org.dbunit.database=ERROR

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/2ddaeabf/jdbc/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/jdbc/src/main/resources/log4j.properties b/jdbc/src/main/resources/log4j.properties
deleted file mode 100644
index 3707ba8..0000000
--- a/jdbc/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-#define appenders
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%t]:[%d{yyyy-MM-dd HH:mm:ss,SSS}][%p][%l] - %m%n
-
-log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.File=kylin_jdbc.log
-log4j.appender.file.layout.ConversionPattern=[%t]:[%d{yyyy-MM-dd HH:mm:ss,SSS}][%p][%l] - %m%n
-log4j.appender.file.Append=true
-
-#overall config
-log4j.rootLogger=DEBUG,stdout,file
-#log4j.logger.org.apache.kylin=DEBUG,stdout,file
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/2ddaeabf/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java b/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
index 2db3b67..18730ef 100644
--- a/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
+++ b/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
@@ -35,6 +35,8 @@ public class DebugTomcat {
 
     public static void setupDebugEnv() {
         try {
+            System.setProperty("log4j.configuration", "kylin-log4j.properties");
+            
             // test_case_data/sandbox/ contains HDP 2.2 site xmls which is dev sandbox
             ClasspathUtil.addClasspath(new File("../examples/test_case_data/sandbox").getAbsolutePath());
             System.setProperty(KylinConfig.KYLIN_CONF, "../examples/test_case_data/sandbox");

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/2ddaeabf/server/src/main/java/org/apache/kylin/rest/util/Log4jConfigListener.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/util/Log4jConfigListener.java b/server/src/main/java/org/apache/kylin/rest/util/Log4jConfigListener.java
new file mode 100644
index 0000000..19c76ea
--- /dev/null
+++ b/server/src/main/java/org/apache/kylin/rest/util/Log4jConfigListener.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kylin.rest.util;
+
+import javax.servlet.ServletContextEvent;
+
+public class Log4jConfigListener extends org.springframework.web.util.Log4jConfigListener {
+
+    private boolean isTesting;
+
+    public Log4jConfigListener() {
+        // set by DebugTomcat
+        this.isTesting = "testing".equals(System.getProperty("spring.profiles.active"));
+    }
+
+    @Override
+    public void contextInitialized(ServletContextEvent event) {
+        if (!isTesting) {
+            super.contextInitialized(event);
+        }
+    }
+
+    @Override
+    public void contextDestroyed(ServletContextEvent event) {
+        if (!isTesting) {
+            super.contextDestroyed(event);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/2ddaeabf/server/src/main/resources/kylin-server-log4j.properties
----------------------------------------------------------------------
diff --git a/server/src/main/resources/kylin-server-log4j.properties b/server/src/main/resources/kylin-server-log4j.properties
new file mode 100644
index 0000000..6ccd161
--- /dev/null
+++ b/server/src/main/resources/kylin-server-log4j.properties
@@ -0,0 +1,51 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#define appenders
+log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.File=${catalina.home}/logs/kylin.log
+log4j.appender.file.layout.ConversionPattern=[%t]:[%d{yyyy-MM-dd HH:mm:ss,SSS}][%p][%l] - %m%n
+log4j.appender.file.Append=true
+
+log4j.appender.query=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.query.layout=org.apache.log4j.PatternLayout
+log4j.appender.query.File=${catalina.home}/logs/kylin_query.log
+log4j.appender.query.layout.ConversionPattern=[%t]:[%d{yyyy-MM-dd HH:mm:ss,SSS}][%p][%l] - %m%n
+log4j.appender.query.Append=true
+
+log4j.appender.job=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.job.layout=org.apache.log4j.PatternLayout
+log4j.appender.job.File=${catalina.home}/logs/kylin_job.log
+log4j.appender.job.layout.ConversionPattern=[%t]:[%d{yyyy-MM-dd HH:mm:ss,SSS}][%p][%l] - %m%n
+log4j.appender.job.Append=true
+
+#overall config
+log4j.rootLogger=INFO,file
+log4j.logger.org.apache.kylin=DEBUG
+log4j.logger.org.springframework=WARN
+
+#query config
+log4j.logger.org.apache.kylin.rest.controller.QueryController=DEBUG, query
+log4j.logger.org.apache.kylin.rest.service.QueryService=DEBUG, query
+log4j.logger.org.apache.kylin.query=DEBUG, query
+log4j.logger.org.apache.kylin.storage=DEBUG, query
+
+#job config
+log4j.logger.org.apache.kylin.rest.controller.JobController=DEBUG, job
+log4j.logger.org.apache.kylin.rest.service.JobService=DEBUG, job
+log4j.logger.org.apache.kylin.job=DEBUG, job

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/2ddaeabf/server/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/server/src/main/resources/log4j.properties b/server/src/main/resources/log4j.properties
deleted file mode 100644
index ef4bff4..0000000
--- a/server/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,38 +0,0 @@
-#define appenders
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%t]:[%d{yyyy-MM-dd HH:mm:ss,SSS}][%p][%l] - %m%n
-
-log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.File=${catalina.home}/logs/kylin.log
-log4j.appender.file.layout.ConversionPattern=[%t]:[%d{yyyy-MM-dd HH:mm:ss,SSS}][%p][%l] - %m%n
-log4j.appender.file.Append=true
-
-log4j.appender.query=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.query.layout=org.apache.log4j.PatternLayout
-log4j.appender.query.File=${catalina.home}/logs/kylin_query.log
-log4j.appender.query.layout.ConversionPattern=[%t]:[%d{yyyy-MM-dd HH:mm:ss,SSS}][%p][%l] - %m%n
-log4j.appender.query.Append=true
-
-log4j.appender.job=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.job.layout=org.apache.log4j.PatternLayout
-log4j.appender.job.File=${catalina.home}/logs/kylin_job.log
-log4j.appender.job.layout.ConversionPattern=[%t]:[%d{yyyy-MM-dd HH:mm:ss,SSS}][%p][%l] - %m%n
-log4j.appender.job.Append=true
-
-#overall config
-log4j.rootLogger=INFO,stdout,file
-log4j.logger.org.apache.kylin=DEBUG
-log4j.logger.org.springframework=WARN
-
-#query config
-log4j.logger.org.apache.kylin.rest.controller.QueryController=DEBUG, query
-log4j.logger.org.apache.kylin.rest.service.QueryService=DEBUG, query
-log4j.logger.org.apache.kylin.query=DEBUG, query
-log4j.logger.org.apache.kylin.storage=DEBUG, query
-
-#job config
-log4j.logger.org.apache.kylin.rest.controller.JobController=DEBUG, job
-log4j.logger.org.apache.kylin.rest.service.JobService=DEBUG, job
-log4j.logger.org.apache.kylin.job=DEBUG, job
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/2ddaeabf/server/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/server/src/main/webapp/WEB-INF/web.xml b/server/src/main/webapp/WEB-INF/web.xml
index d52b924..fbbb1cd 100644
--- a/server/src/main/webapp/WEB-INF/web.xml
+++ b/server/src/main/webapp/WEB-INF/web.xml
@@ -5,7 +5,7 @@
 		  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
            version="2.5">
 
-    <display-name>Kylin RESt Service</display-name>
+    <display-name>Kylin REST Service</display-name>
 
     <welcome-file-list>
         <welcome-file>/index.html</welcome-file>
@@ -18,7 +18,7 @@
 
     <context-param>
         <param-name>log4jConfigLocation</param-name>
-        <param-value>classpath:log4j.properties</param-value>
+        <param-value>classpath:kylin-server-log4j.properties</param-value>
     </context-param>
     <context-param>
         <param-name>contextConfigLocation</param-name>
@@ -30,7 +30,7 @@
     </context-param>
 
     <listener>
-        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
+        <listener-class>org.apache.kylin.rest.util.Log4jConfigListener</listener-class>
     </listener>
 
     <listener>