ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject ambari git commit: AMBARI-12685 - EclipseLink stdout Log Statements Fill Up Disk Space (jonathanhurley)
Date Mon, 10 Aug 2015 16:17:31 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 37bcf4123 -> d6405682d


AMBARI-12685 - EclipseLink stdout Log Statements Fill Up Disk Space (jonathanhurley)


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

Branch: refs/heads/branch-2.1
Commit: d6405682d0ac49518a04dd140bde98143aa21283
Parents: 37bcf41
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Sat Aug 8 22:13:17 2015 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Mon Aug 10 12:17:24 2015 -0400

----------------------------------------------------------------------
 ambari-server/conf/unix/log4j.properties        |  11 ++
 ambari-server/conf/windows/log4j.properties     |  12 +-
 ambari-server/src/main/conf/log4j.properties    |  12 +-
 .../server/logging/EclipseLinkLogger.java       | 132 +++++++++++++++++++
 .../src/main/resources/META-INF/persistence.xml |   7 +-
 5 files changed, 170 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d6405682/ambari-server/conf/unix/log4j.properties
----------------------------------------------------------------------
diff --git a/ambari-server/conf/unix/log4j.properties b/ambari-server/conf/unix/log4j.properties
index f619c6c..c87b1f4 100644
--- a/ambari-server/conf/unix/log4j.properties
+++ b/ambari-server/conf/unix/log4j.properties
@@ -22,6 +22,7 @@ ambari.log.dir=/var/log/ambari-server
 ambari.log.file=ambari-server.log
 ambari.config-changes.file=ambari-config-changes.log
 ambari.alerts.file=ambari-alerts.log
+ambari.eclipselink.file=ambari-eclipselink.log
 
 log4j.rootLogger=INFO,file
 
@@ -49,6 +50,16 @@ log4j.appender.alerts.File=${ambari.log.dir}/${ambari.alerts.file}
 log4j.appender.alerts.layout=org.apache.log4j.PatternLayout
 log4j.appender.alerts.layout.ConversionPattern=%d{ISO8601} %m%n
 
+# EclipsLink -> slf4j bridge
+log4j.logger.eclipselink=TRACE,eclipselink
+log4j.additivity.eclipselink=false
+log4j.appender.eclipselink=org.apache.log4j.RollingFileAppender
+log4j.appender.eclipselink.File=${ambari.log.dir}/${ambari.eclipselink.file}
+log4j.appender.eclipselink.MaxFileSize=50MB
+log4j.appender.eclipselink.MaxBackupIndex=10
+log4j.appender.eclipselink.layout=org.apache.log4j.PatternLayout
+log4j.appender.eclipselink.layout.ConversionPattern=%m%n
+
 log4j.logger.org.apache.hadoop.yarn.client=WARN
 log4j.logger.org.apache.slider.common.tools.SliderUtils=WARN
 log4j.logger.org.apache.ambari.server.security.authorization=WARN

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6405682/ambari-server/conf/windows/log4j.properties
----------------------------------------------------------------------
diff --git a/ambari-server/conf/windows/log4j.properties b/ambari-server/conf/windows/log4j.properties
index 607cdf9..8a69508 100644
--- a/ambari-server/conf/windows/log4j.properties
+++ b/ambari-server/conf/windows/log4j.properties
@@ -22,7 +22,7 @@ ambari.log.dir=\\var\\log\\ambari-server\\
 ambari.log.file=ambari-server.log
 ambari.config-changes.file=ambari-config-changes.log
 ambari.alerts.file=ambari-alerts.log
-
+ambari.eclipselink.file=ambari-eclipselink.log
 
 # Define the root logger to the system property "ambari.root.logger".
 log4j.rootLogger=${ambari.root.logger}
@@ -75,3 +75,13 @@ log4j.appender.alerts=org.apache.log4j.FileAppender
 log4j.appender.alerts.File=${ambari.log.dir}\${ambari.alerts.file}
 log4j.appender.alerts.layout=org.apache.log4j.PatternLayout
 log4j.appender.alerts.layout.ConversionPattern=%d{ISO8601} %m%n
+
+# EclipsLink -> slf4j bridge
+log4j.logger.eclipselink=TRACE,eclipselink
+log4j.additivity.eclipselink=false
+log4j.appender.eclipselink=org.apache.log4j.RollingFileAppender
+log4j.appender.eclipselink.File=${ambari.log.dir}/${ambari.eclipselink.file}
+log4j.appender.eclipselink.MaxFileSize=50MB
+log4j.appender.eclipselink.MaxBackupIndex=10
+log4j.appender.eclipselink.layout=org.apache.log4j.PatternLayout
+log4j.appender.eclipselink.layout.ConversionPattern=%m%n

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6405682/ambari-server/src/main/conf/log4j.properties
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/conf/log4j.properties b/ambari-server/src/main/conf/log4j.properties
index 6d53ca3..11e8d51 100644
--- a/ambari-server/src/main/conf/log4j.properties
+++ b/ambari-server/src/main/conf/log4j.properties
@@ -22,7 +22,7 @@ ambari.log.dir=/var/log/ambari-server
 ambari.log.file=ambari-server.log
 ambari.config-changes.file=ambari-config-changes.log
 ambari.alerts.file=ambari-alerts.log
-
+ambari.eclipselink.file=ambari-eclipselink.log
 
 # Define the root logger to the system property "ambari.root.logger".
 log4j.rootLogger=${ambari.root.logger}
@@ -76,3 +76,13 @@ log4j.appender.alerts.File=${ambari.log.dir}/${ambari.alerts.file}
 log4j.appender.alerts.layout=org.apache.log4j.PatternLayout
 log4j.appender.alerts.layout.ConversionPattern=%d{ISO8601} %m%n
 
+# EclipsLink -> slf4j bridge
+log4j.logger.eclipselink=TRACE,eclipselink
+log4j.additivity.eclipselink=false
+log4j.appender.eclipselink=org.apache.log4j.RollingFileAppender
+log4j.appender.eclipselink.File=${ambari.log.dir}/${ambari.eclipselink.file}
+log4j.appender.eclipselink.MaxFileSize=50MB
+log4j.appender.eclipselink.MaxBackupIndex=10
+log4j.appender.eclipselink.layout=org.apache.log4j.PatternLayout
+log4j.appender.eclipselink.layout.ConversionPattern=%m%n
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6405682/ambari-server/src/main/java/org/apache/ambari/server/logging/EclipseLinkLogger.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/logging/EclipseLinkLogger.java
b/ambari-server/src/main/java/org/apache/ambari/server/logging/EclipseLinkLogger.java
new file mode 100644
index 0000000..388a3ec
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/logging/EclipseLinkLogger.java
@@ -0,0 +1,132 @@
+/**
+ * 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.ambari.server.logging;
+
+import org.eclipse.persistence.logging.AbstractSessionLog;
+import org.eclipse.persistence.logging.SessionLog;
+import org.eclipse.persistence.logging.SessionLogEntry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The {@link EclipseLinkLogger} is a bridge between EclipseLink's internal
+ * logging framework and SLF4J. EclipseLink does not have a rolling log, which
+ * means that the standard output file can grow large and cause disk space
+ * issues. This logger translates the following log levels:
+ * <table>
+ * <tr>
+ * <td>EclipseLink</td>
+ * <td>SLF4J</td>
+ * </tr>
+ * <tr>
+ * <td>ALL</td>
+ * <td>TRACE</td>
+ * </tr>
+ * <tr>
+ * <td>FINER</td>
+ * <td>TRACE</td>
+ * </tr>
+ * <tr>
+ * <td>FINEST</td>
+ * <td>TRACE</td>
+ * </tr>
+ * <tr>
+ * <td>FINE</td>
+ * <td>DEBUG</td>
+ * </tr>
+ * <tr>
+ * <td>INFO</td>
+ * <td>INFO</td>
+ * </tr>
+ * <tr>
+ * <td>CONFIG</td>
+ * <td>INFO</td>
+ * </tr>
+ * <tr>
+ * <td>SEVERE</td>
+ * <td>ERROR</td>
+ * </tr>
+ * <tr>
+ * <td>WARNING</td>
+ * <td>WARN</td>
+ * </tr>
+ * <tr>
+ * <td>OFF</td>
+ * <td>-</td>
+ * </tr>
+ * </table>
+ * <p/>
+ * Logging is still configured for EclipseLink via {@code persistence.xml}.
+ */
+public class EclipseLinkLogger extends AbstractSessionLog implements SessionLog {
+
+  /**
+   * A logger that is only for creating a bridge between EclipseLink's internal
+   * logger and log4j.
+   */
+  private static final Logger JPA_LOG = LoggerFactory.getLogger("eclipselink");
+
+  /**
+   * The log template to use to create statements similar to EclipseLink's
+   * internal logger.
+   */
+  private static final String LOG_TEMPLATE = "[EL {}]: {} {}";
+
+  @Override
+  public void log(SessionLogEntry sessionLogEntry) {
+    // use the EclipseLink log level to determine if this should be logged
+    int level = sessionLogEntry.getLevel();
+    if (!shouldLog(level, sessionLogEntry.getNameSpace())) {
+      return;
+    }
+
+    switch (level) {
+      case SessionLog.ALL:
+      case SessionLog.FINER:
+      case SessionLog.FINEST:
+        JPA_LOG.trace(LOG_TEMPLATE, "Trace", getSupplementDetailString(sessionLogEntry),
+            formatMessage(sessionLogEntry));
+        return;
+      case SessionLog.INFO:
+      case SessionLog.CONFIG:
+        JPA_LOG.info(LOG_TEMPLATE, "Info", getSupplementDetailString(sessionLogEntry),
+            formatMessage(sessionLogEntry));
+        return;
+      case SessionLog.FINE:
+        JPA_LOG.debug(LOG_TEMPLATE, "Debug", getSupplementDetailString(sessionLogEntry),
+            formatMessage(sessionLogEntry));
+        return;
+      case SessionLog.SEVERE:
+        // always log
+        JPA_LOG.error(LOG_TEMPLATE, "Error", getSupplementDetailString(sessionLogEntry),
+            formatMessage(sessionLogEntry));
+        return;
+      case SessionLog.WARNING:
+        JPA_LOG.warn(LOG_TEMPLATE, "Warning", getSupplementDetailString(sessionLogEntry),
+            formatMessage(sessionLogEntry));
+        return;
+      case SessionLog.OFF:
+        // never log
+        return;
+      default:
+        JPA_LOG.debug(LOG_TEMPLATE, "Unknown", getSupplementDetailString(sessionLogEntry),
+            formatMessage(sessionLogEntry));
+        return;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6405682/ambari-server/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/META-INF/persistence.xml b/ambari-server/src/main/resources/META-INF/persistence.xml
index deb30bb..9a8683a 100644
--- a/ambari-server/src/main/resources/META-INF/persistence.xml
+++ b/ambari-server/src/main/resources/META-INF/persistence.xml
@@ -9,8 +9,7 @@
   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. -->
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
-  version="2.0">
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
 
   <persistence-unit name="ambari-server" transaction-type="RESOURCE_LOCAL">
     <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
@@ -96,6 +95,8 @@
       <property name="eclipselink.connection-pool.sequence" value="true" />
       <property name="eclipselink.weaving" value="static" />
       <property name="eclipselink.session.customizer" value="org.apache.ambari.server.orm.EclipseLinkSessionCustomizer"/>
+      <property name="eclipselink.logging.logger" value="org.apache.ambari.server.logging.EclipseLinkLogger"/>
+      <property name="eclipselink.logging.level" value="INFO"/>
     </properties>
   </persistence-unit>
 
@@ -107,6 +108,8 @@
       <property name="eclipselink.cache.size.default" value="10000" />
       <property name="eclipselink.jdbc.batch-writing" value="JDBC"/>
       <property name="eclipselink.weaving" value="static" />
+      <property name="eclipselink.logging.logger" value="org.apache.ambari.server.logging.EclipseLinkLogger"/>
+      <property name="eclipselink.logging.level" value="INFO"/>
     </properties>
   </persistence-unit>
 </persistence>


Mime
View raw message