Murtadha Hubail has uploaded a new change for review.
https://asterix-gerrit.ics.uci.edu/2335
Change subject: [ASTERIXDB-1554][CONF] Do Not Override Logger Config
......................................................................
[ASTERIXDB-1554][CONF] Do Not Override Logger Config
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Do not override logger config for hyracks/asterix
roots if they are already configured.
Change-Id: Iff7ed7c094d9044f5959f9e24713302af9774786
---
M
asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
M
hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/BaseCCApplication.java
A
hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/LoggingConfigUtil.java
3 files changed, 53 insertions(+), 7 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/35/2335/1
diff --git
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
index 6baf488..0a8d52b 100644
---
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
+++
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
@@ -94,14 +94,15 @@
import org.apache.hyracks.http.api.IServlet;
import org.apache.hyracks.http.server.HttpServer;
import org.apache.hyracks.http.server.WebManager;
+import org.apache.hyracks.util.LoggingConfigUtil;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.Configurator;
public class CCApplication extends BaseCCApplication {
private static final Logger LOGGER = LogManager.getLogger();
+ private static final String ASTERIX_LOGGER_NAME = "org.apache.asterix";
private static IAsterixStateProxy proxy;
protected ICCServiceContext ccServiceCtx;
protected CCExtensionManager ccExtensionManager;
@@ -191,8 +192,7 @@
@Override
protected void configureLoggingLevel(Level level) {
super.configureLoggingLevel(level);
- LOGGER.info("Setting Asterix log level to " + level);
- Configurator.setLevel("org.apache.asterix", level);
+ LoggingConfigUtil.defaultIfMissing(ASTERIX_LOGGER_NAME, level);
}
protected List<AsterixExtension> getExtensions() {
diff --git
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/BaseCCApplication.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/BaseCCApplication.java
index a7a64cc..3d04a56 100644
---
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/BaseCCApplication.java
+++
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/BaseCCApplication.java
@@ -29,14 +29,15 @@
import org.apache.hyracks.control.common.controllers.CCConfig;
import org.apache.hyracks.control.common.controllers.ControllerConfig;
import org.apache.hyracks.control.common.controllers.NCConfig;
+import org.apache.hyracks.util.LoggingConfigUtil;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.Configurator;
public class BaseCCApplication implements ICCApplication {
- private static final Logger LOGGER = LogManager.getLogger();
+
public static final ICCApplication INSTANCE = new BaseCCApplication();
+ private static final String HYRACKS_LOGGER_NAME = "org.apache.hyracks";
private IConfigManager configManager;
protected BaseCCApplication() {
@@ -84,8 +85,7 @@
}
protected void configureLoggingLevel(Level level) {
- LOGGER.info("Setting Hyracks log level to " + level);
- Configurator.setLevel("org.apache.hyracks", level);
+ LoggingConfigUtil.defaultIfMissing(HYRACKS_LOGGER_NAME, level);
}
@Override
diff --git
a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/LoggingConfigUtil.java
b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/LoggingConfigUtil.java
new file mode 100644
index 0000000..9ed3c31
--- /dev/null
+++
b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/LoggingConfigUtil.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.hyracks.util;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.Configurator;
+import org.apache.logging.log4j.core.config.LoggerConfig;
+
+public class LoggingConfigUtil {
+
+ private static final Logger LOGGER = LogManager.getLogger();
+
+ private LoggingConfigUtil() {
+ }
+
+ public static void defaultIfMissing(String logger, Level defaultLvl) {
+ final Configuration loggingConfig =
LoggerContext.getContext().getConfiguration();
+ final LoggerConfig loggerConfig =
loggingConfig.getLoggers().get(logger);
+ if (loggerConfig != null) {
+ LOGGER.info("{} log level is ", loggerConfig.getLevel());
+ } else {
+ LOGGER.info("Setting {} log level to {}", logger, defaultLvl);
+ Configurator.setLevel(logger, defaultLvl);
+ }
+ }
+}
--
To view, visit https://asterix-gerrit.ics.uci.edu/2335
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iff7ed7c094d9044f5959f9e24713302af9774786
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Murtadha Hubail <[email protected]>