From a279d5c453c6e6f00ab937fa3e6745fdf68e82b2 Mon Sep 17 00:00:00 2001 From: harikrishna-patnala Date: Wed, 17 Jun 2020 07:11:23 +0530 Subject: [PATCH] logging: Logging framework to use only log4j (#4003) Currently CloudStack is using logging frameworks as log4j and Java util logging, logging wrappers as slf4j and Apache common logging. Here changes are to made it uniform, using only log4j framework. Removed Java util logging, slf4j and Apache common logging. --- .../src/main/java/com/cloud/agent/Agent.java | 2 +- .../command/admin/account/LockAccountCmd.java | 2 +- .../router/UpgradeRouterTemplateCmd.java | 2 +- .../command/admin/user/GetUserKeysCmd.java | 2 +- .../user/vmsnapshot/CreateVMSnapshotCmd.java | 2 +- .../vmsnapshot/RevertToVMSnapshotCmd.java | 2 +- .../apache/cloudstack/context/LogContext.java | 2 +- client/conf/commons-logging.properties.in | 30 ------------------- .../org/apache/cloudstack/ServerDaemon.java | 5 ++-- .../cloud/agent/manager/AgentManagerImpl.java | 7 +++-- .../agent/manager/DirectAgentAttache.java | 2 +- .../jobs/impl/AsyncJobManagerImpl.java | 2 +- framework/managed-context/pom.xml | 5 ++-- .../context/ManagedContextRunnable.java | 5 ++-- .../context/impl/DefaultManagedContext.java | 9 +++--- .../threadlocal/ManagedThreadLocal.java | 5 ++-- .../CloudStackExtendedLifeCycle.java | 9 +++--- .../lifecycle/registry/DumpRegistry.java | 7 ++--- .../lifecycle/registry/ExtensionRegistry.java | 7 ++--- .../lifecycle/registry/RegistryLifecycle.java | 9 +++--- .../factory/CloudStackSpringContext.java | 7 ++--- .../impl/DefaultModuleDefinitionSet.java | 13 ++++---- .../web/CloudStackContextLoaderListener.java | 5 ++-- packaging/centos7/cloud.spec | 3 +- pom.xml | 11 ------- usage/pom.xml | 8 ----- utils/pom.xml | 8 ----- .../backoff/impl/ConstantTimeBackoff.java | 7 ++--- .../com/cloud/utils/xmlobject/XmlObject.java | 2 +- .../ssl/EasySSLProtocolSocketFactory.java | 5 ++-- .../contrib/ssl/EasyX509TrustManager.java | 7 ++--- .../backoff/impl/ConstantTimeBackoffTest.java | 5 ++-- 32 files changed, 62 insertions(+), 135 deletions(-) delete mode 100644 client/conf/commons-logging.properties.in diff --git a/agent/src/main/java/com/cloud/agent/Agent.java b/agent/src/main/java/com/cloud/agent/Agent.java index 7e5e2957f59..a9da4217168 100644 --- a/agent/src/main/java/com/cloud/agent/Agent.java +++ b/agent/src/main/java/com/cloud/agent/Agent.java @@ -51,7 +51,7 @@ import org.apache.cloudstack.utils.security.KeyStoreUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; -import org.slf4j.MDC; +import org.apache.log4j.MDC; import com.cloud.agent.api.AgentControlAnswer; import com.cloud.agent.api.AgentControlCommand; diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/account/LockAccountCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/account/LockAccountCmd.java index 05b370abda5..d02902d9800 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/account/LockAccountCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/account/LockAccountCmd.java @@ -16,7 +16,7 @@ // under the License. package org.apache.cloudstack.api.command.admin.account; -import java.util.logging.Logger; +import org.apache.log4j.Logger; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java index 65d26cc7f96..fedc314be7f 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java @@ -17,7 +17,7 @@ package org.apache.cloudstack.api.command.admin.router; import java.util.List; -import java.util.logging.Logger; +import org.apache.log4j.Logger; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/user/GetUserKeysCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/user/GetUserKeysCmd.java index f93c6e11728..5878473b5e1 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/user/GetUserKeysCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/user/GetUserKeysCmd.java @@ -29,7 +29,7 @@ import org.apache.cloudstack.api.response.RegisterResponse; import org.apache.cloudstack.api.response.UserResponse; import java.util.Map; -import java.util.logging.Logger; +import org.apache.log4j.Logger; @APICommand(name = GetUserKeysCmd.APINAME, description = "This command allows the user to query the seceret and API keys for the account", diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java index e89f6ccb310..7cb3194e970 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java @@ -17,7 +17,7 @@ package org.apache.cloudstack.api.command.user.vmsnapshot; -import java.util.logging.Logger; +import org.apache.log4j.Logger; import com.cloud.vm.VirtualMachine; import org.apache.cloudstack.acl.SecurityChecker.AccessType; diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToVMSnapshotCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToVMSnapshotCmd.java index 9076ac2a8b3..86562ad97b3 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToVMSnapshotCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToVMSnapshotCmd.java @@ -16,7 +16,7 @@ // under the License. package org.apache.cloudstack.api.command.user.vmsnapshot; -import java.util.logging.Logger; +import org.apache.log4j.Logger; import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.api.ACL; diff --git a/api/src/main/java/org/apache/cloudstack/context/LogContext.java b/api/src/main/java/org/apache/cloudstack/context/LogContext.java index 9bc9ed738ec..20ea82ad8ef 100644 --- a/api/src/main/java/org/apache/cloudstack/context/LogContext.java +++ b/api/src/main/java/org/apache/cloudstack/context/LogContext.java @@ -21,7 +21,7 @@ import java.util.Map; import java.util.UUID; import org.apache.log4j.Logger; -import org.slf4j.MDC; +import org.apache.log4j.MDC; import org.apache.cloudstack.managed.threadlocal.ManagedThreadLocal; diff --git a/client/conf/commons-logging.properties.in b/client/conf/commons-logging.properties.in deleted file mode 100644 index febd7ba23ae..00000000000 --- a/client/conf/commons-logging.properties.in +++ /dev/null @@ -1,30 +0,0 @@ -# -# 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. -# - -# This is the logging properties that goes to the war, there are two logging conf kept at the -# svn, one for developement (one at src/test-resources) and other for producation - -# Uncomment the next line to disable all logging. -#org.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog - -# Uncomment the next line to enable the simple log based logging -#org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog - -# Uncomment the next line to enable log4j based logging -org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger diff --git a/client/src/main/java/org/apache/cloudstack/ServerDaemon.java b/client/src/main/java/org/apache/cloudstack/ServerDaemon.java index 12c5f981466..0016773e2d1 100644 --- a/client/src/main/java/org/apache/cloudstack/ServerDaemon.java +++ b/client/src/main/java/org/apache/cloudstack/ServerDaemon.java @@ -46,8 +46,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; import org.eclipse.jetty.webapp.WebAppContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import com.cloud.utils.PropertiesUtil; import com.google.common.base.Strings; @@ -58,7 +57,7 @@ import com.google.common.base.Strings; * Configuration parameters are read from server.properties file available on the classpath. */ public class ServerDaemon implements Daemon { - private static final Logger LOG = LoggerFactory.getLogger(ServerDaemon.class); + private static final Logger LOG = Logger.getLogger(ServerDaemon.class); private static final String WEB_XML = "META-INF/webapp/WEB-INF/web.xml"; ///////////////////////////////////////////////////// diff --git a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java index e80d3ec2d94..0ad7fe0a1d8 100644 --- a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java @@ -49,7 +49,7 @@ import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.cloudstack.outofbandmanagement.dao.OutOfBandManagementDao; import org.apache.cloudstack.utils.identity.ManagementServerNode; import org.apache.log4j.Logger; -import org.slf4j.MDC; +import org.apache.log4j.MDC; import com.cloud.agent.AgentManager; import com.cloud.agent.Listener; @@ -388,8 +388,9 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl cmd.setContextParam("job", "job-" + job.getId()); } } - if (MDC.get("logcontextid") != null && !MDC.get("logcontextid").isEmpty()) { - cmd.setContextParam("logid", MDC.get("logcontextid")); + String logcontextid = (String) MDC.get("logcontextid"); + if (!Strings.isNullOrEmpty(logcontextid)) { + cmd.setContextParam("logid", logcontextid); } } diff --git a/engine/orchestration/src/main/java/com/cloud/agent/manager/DirectAgentAttache.java b/engine/orchestration/src/main/java/com/cloud/agent/manager/DirectAgentAttache.java index be4d029a000..6514685aa46 100644 --- a/engine/orchestration/src/main/java/com/cloud/agent/manager/DirectAgentAttache.java +++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/DirectAgentAttache.java @@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.log4j.Logger; import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.managed.context.ManagedContextRunnable; -import org.slf4j.MDC; +import org.apache.log4j.MDC; import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; diff --git a/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java b/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java index cb04d22d9e0..74b47eb256c 100644 --- a/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java +++ b/framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java @@ -60,7 +60,7 @@ import org.apache.cloudstack.jobs.JobInfo; import org.apache.cloudstack.jobs.JobInfo.Status; import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.cloudstack.utils.identity.ManagementServerNode; -import org.slf4j.MDC; +import org.apache.log4j.MDC; import com.cloud.cluster.ClusterManagerListener; import org.apache.cloudstack.management.ManagementServerHost; diff --git a/framework/managed-context/pom.xml b/framework/managed-context/pom.xml index 5629085e1d5..436f3dc7dd0 100644 --- a/framework/managed-context/pom.xml +++ b/framework/managed-context/pom.xml @@ -29,8 +29,9 @@ - org.slf4j - slf4j-api + log4j + log4j + ${cs.log4j.version} diff --git a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java index b4a9758420b..da8265c5bd2 100644 --- a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java +++ b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java @@ -18,8 +18,7 @@ */ package org.apache.cloudstack.managed.context; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import org.apache.cloudstack.managed.context.impl.DefaultManagedContext; @@ -27,7 +26,7 @@ public abstract class ManagedContextRunnable implements Runnable { private static final int SLEEP_COUNT = 120; - private static final Logger log = LoggerFactory.getLogger(ManagedContextRunnable.class); + private static final Logger log = Logger.getLogger(ManagedContextRunnable.class); private static final ManagedContext DEFAULT_MANAGED_CONTEXT = new DefaultManagedContext(); private static ManagedContext context; private static boolean managedContext = false; diff --git a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/impl/DefaultManagedContext.java b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/impl/DefaultManagedContext.java index 34c83b1d332..76e6d458028 100644 --- a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/impl/DefaultManagedContext.java +++ b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/impl/DefaultManagedContext.java @@ -23,8 +23,7 @@ import java.util.Stack; import java.util.concurrent.Callable; import java.util.concurrent.CopyOnWriteArrayList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import org.apache.cloudstack.managed.context.ManagedContext; import org.apache.cloudstack.managed.context.ManagedContextListener; @@ -33,7 +32,7 @@ import org.apache.cloudstack.managed.threadlocal.ManagedThreadLocal; public class DefaultManagedContext implements ManagedContext { - private static final Logger log = LoggerFactory.getLogger(DefaultManagedContext.class); + private static final Logger log = Logger.getLogger(DefaultManagedContext.class); List> listeners = new CopyOnWriteArrayList>(); @@ -88,7 +87,7 @@ public class DefaultManagedContext implements ManagedContext { if (firstError == null) { firstError = t; } - log.error("Failed onEnterContext for listener [{}]", listener, t); + log.error("Failed onEnterContext for listener: " + listener, t); } /* Stack data structure is used because in between onEnter and onLeave @@ -114,7 +113,7 @@ public class DefaultManagedContext implements ManagedContext { invocation.listener.onLeaveContext(invocation.data, reentry); } catch (Throwable t) { lastError = t; - log.error("Failed onLeaveContext for listener [{}]", invocation.listener, t); + log.error("Failed onLeaveContext for listener: [" + invocation.listener + "]", t); } } diff --git a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/threadlocal/ManagedThreadLocal.java b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/threadlocal/ManagedThreadLocal.java index 2db3aafcf5c..f323d9a212a 100644 --- a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/threadlocal/ManagedThreadLocal.java +++ b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/threadlocal/ManagedThreadLocal.java @@ -21,8 +21,7 @@ package org.apache.cloudstack.managed.threadlocal; import java.util.HashMap; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import org.apache.cloudstack.managed.context.ManagedContextUtils; @@ -36,7 +35,7 @@ public class ManagedThreadLocal extends ThreadLocal { }; private static boolean s_validateContext = false; - private static final Logger log = LoggerFactory.getLogger(ManagedThreadLocal.class); + private static final Logger log = Logger.getLogger(ManagedThreadLocal.class); @SuppressWarnings("unchecked") @Override diff --git a/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/CloudStackExtendedLifeCycle.java b/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/CloudStackExtendedLifeCycle.java index fd9c886604c..b0c1dcc0760 100644 --- a/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/CloudStackExtendedLifeCycle.java +++ b/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/CloudStackExtendedLifeCycle.java @@ -29,8 +29,7 @@ import javax.management.MalformedObjectNameException; import javax.management.NotCompliantMBeanException; import javax.naming.ConfigurationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import com.cloud.utils.component.ComponentLifecycle; import com.cloud.utils.component.SystemIntegrityChecker; @@ -40,7 +39,7 @@ import com.cloud.utils.mgmt.ManagementBean; public class CloudStackExtendedLifeCycle extends AbstractBeanCollector { - private static final Logger log = LoggerFactory.getLogger(CloudStackExtendedLifeCycle.class); + private static final Logger log = Logger.getLogger(CloudStackExtendedLifeCycle.class); Map> sorted = new TreeMap>(); @@ -60,7 +59,7 @@ public class CloudStackExtendedLifeCycle extends AbstractBeanCollector { protected void checkIntegrity() { for (SystemIntegrityChecker checker : getBeans(SystemIntegrityChecker.class)) { - log.info("Running system integrity checker {}", checker); + log.info("Running system integrity checker " + checker); checker.check(); } @@ -114,7 +113,7 @@ public class CloudStackExtendedLifeCycle extends AbstractBeanCollector { try { lifecycle.configure(lifecycle.getName(), lifecycle.getConfigParams()); } catch (ConfigurationException e) { - log.error("Failed to configure {}", lifecycle.getName(), e); + log.error("Failed to configure " + lifecycle.getName(), e); throw new CloudRuntimeException(e); } } diff --git a/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/DumpRegistry.java b/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/DumpRegistry.java index 79e35f11d0c..5c5e9165b17 100644 --- a/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/DumpRegistry.java +++ b/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/DumpRegistry.java @@ -22,8 +22,7 @@ import java.util.List; import javax.inject.Inject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import com.cloud.utils.component.ComponentLifecycleBase; import com.cloud.utils.component.Named; @@ -31,7 +30,7 @@ import com.cloud.utils.component.Registry; public class DumpRegistry extends ComponentLifecycleBase { - private static final Logger log = LoggerFactory.getLogger(DumpRegistry.class); + private static final Logger log = Logger.getLogger(DumpRegistry.class); List> registries; @@ -56,7 +55,7 @@ public class DumpRegistry extends ComponentLifecycleBase { buffer.append(getName(o)); } - log.info("Registry [{}] contains [{}]", registry.getName(), buffer); + log.info("Registry [" + registry.getName() + "] contains [" + buffer + "]"); } return super.start(); diff --git a/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/ExtensionRegistry.java b/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/ExtensionRegistry.java index 321e365e2c1..ebb5b5f7800 100644 --- a/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/ExtensionRegistry.java +++ b/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/ExtensionRegistry.java @@ -28,8 +28,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import javax.annotation.PostConstruct; import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanNameAware; import org.apache.cloudstack.framework.config.ConfigKey; @@ -39,7 +38,7 @@ import com.cloud.utils.component.Registry; public class ExtensionRegistry implements Registry, Configurable, BeanNameAware { - private static final Logger log = LoggerFactory.getLogger(ExtensionRegistry.class); + private static final Logger log = Logger.getLogger(ExtensionRegistry.class); String name; String beanName; @@ -112,7 +111,7 @@ public class ExtensionRegistry implements Registry, Configurable, BeanNa registered.add(item); } - log.debug("Registering extension [{}] in [{}]", name, this.name); + log.debug("Registering extension [" + name + "] in [" + this.name + "]"); return true; } diff --git a/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/RegistryLifecycle.java b/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/RegistryLifecycle.java index 337cfbdc52b..43efd846184 100644 --- a/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/RegistryLifecycle.java +++ b/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/RegistryLifecycle.java @@ -23,8 +23,7 @@ import java.util.Iterator; import java.util.Properties; import java.util.Set; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.ApplicationContext; @@ -36,7 +35,7 @@ import com.cloud.utils.component.Registry; public class RegistryLifecycle implements BeanPostProcessor, SmartLifecycle, ApplicationContextAware { - private static final Logger log = LoggerFactory.getLogger(RegistryLifecycle.class); + private static final Logger log = Logger.getLogger(RegistryLifecycle.class); public static final String EXTENSION_EXCLUDE = "extensions.exclude"; public static final String EXTENSION_INCLUDE_PREFIX = "extensions.include."; @@ -71,7 +70,7 @@ public class RegistryLifecycle implements BeanPostProcessor, SmartLifecycle, App boolean result = excludes.contains(name); if (result) { - log.info("Excluding extension [{}] based on configuration", name); + log.info("Excluding extension [" + name + "] based on configuration"); } return result; @@ -110,7 +109,7 @@ public class RegistryLifecycle implements BeanPostProcessor, SmartLifecycle, App while (iter.hasNext()) { Object next = iter.next(); if (registry.register(next)) { - log.debug("Registered {}", next); + log.debug("Registered " + next); } else { iter.remove(); } diff --git a/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/factory/CloudStackSpringContext.java b/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/factory/CloudStackSpringContext.java index 26525dea582..f054d3998ac 100644 --- a/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/factory/CloudStackSpringContext.java +++ b/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/factory/CloudStackSpringContext.java @@ -24,8 +24,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.io.Resource; @@ -37,7 +36,7 @@ import org.apache.cloudstack.spring.module.model.ModuleDefinitionSet; public class CloudStackSpringContext { - private static final Logger log = LoggerFactory.getLogger(CloudStackSpringContext.class); + private static final Logger log = Logger.getLogger(CloudStackSpringContext.class); public static final String CLOUDSTACK_CONTEXT_SERVLET_KEY = CloudStackSpringContext.class.getSimpleName(); public static final String CLOUDSTACK_CONTEXT = "META-INF/cloudstack"; @@ -130,7 +129,7 @@ public class CloudStackSpringContext { String urlString = r.getURL().toExternalForm(); urlList.add(urlString); } catch (IOException e) { - log.error("Failed to create URL for {}", r.getDescription(), e); + log.error("Failed to create URL for " + r.getDescription(), e); } } diff --git a/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/model/impl/DefaultModuleDefinitionSet.java b/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/model/impl/DefaultModuleDefinitionSet.java index bba0dccc53c..5dab5d7bd34 100644 --- a/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/model/impl/DefaultModuleDefinitionSet.java +++ b/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/model/impl/DefaultModuleDefinitionSet.java @@ -33,8 +33,7 @@ import java.util.Set; import java.util.Stack; import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; @@ -49,7 +48,7 @@ import org.apache.cloudstack.spring.module.model.ModuleDefinitionSet; public class DefaultModuleDefinitionSet implements ModuleDefinitionSet { - private static final Logger log = LoggerFactory.getLogger(DefaultModuleDefinitionSet.class); + private static final Logger log = Logger.getLogger(DefaultModuleDefinitionSet.class); public static final String DEFAULT_CONFIG_RESOURCES = "DefaultConfigResources"; public static final String DEFAULT_CONFIG_PROPERTIES = "DefaultConfigProperties"; @@ -101,7 +100,7 @@ public class DefaultModuleDefinitionSet implements ModuleDefinitionSet { ApplicationContext context = getApplicationContext(def.getName()); try { Runnable runnable = context.getBean("moduleStartup", Runnable.class); - log.info("Starting module [{}]", def.getName()); + log.info("Starting module [" + def.getName() + "]"); runnable.run(); } catch (BeansException e) { // Ignore @@ -139,11 +138,11 @@ public class DefaultModuleDefinitionSet implements ModuleDefinitionSet { long start = System.currentTimeMillis(); if (log.isInfoEnabled()) { for (Resource resource : resources) { - log.info("Loading module context [{}] from {}", def.getName(), resource); + log.info("Loading module context [" + def.getName() + "] from " + resource); } } context.refresh(); - log.info("Loaded module context [{}] in {} ms", def.getName(), (System.currentTimeMillis() - start)); + log.info("Loaded module context [" + def.getName() + "] in " + (System.currentTimeMillis() - start) + " ms"); contexts.put(def.getName(), context); @@ -238,7 +237,7 @@ public class DefaultModuleDefinitionSet implements ModuleDefinitionSet { return; if (!shouldLoad(def)) { - log.info("Excluding context [{}] based on configuration", def.getName()); + log.info("Excluding context [" + def.getName() + "] based on configuration"); return; } diff --git a/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/web/CloudStackContextLoaderListener.java b/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/web/CloudStackContextLoaderListener.java index bf6fb24d6a4..a90d6a55340 100644 --- a/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/web/CloudStackContextLoaderListener.java +++ b/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/web/CloudStackContextLoaderListener.java @@ -23,8 +23,7 @@ import java.io.IOException; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import org.springframework.context.ApplicationContext; import org.springframework.web.context.ConfigurableWebApplicationContext; import org.springframework.web.context.ContextLoaderListener; @@ -36,7 +35,7 @@ public class CloudStackContextLoaderListener extends ContextLoaderListener { public static final String WEB_PARENT_MODULE = "parentModule"; public static final String WEB_PARENT_MODULE_DEFAULT = "web"; - private static final Logger log = LoggerFactory.getLogger(CloudStackContextLoaderListener.class); + private static final Logger log = Logger.getLogger(CloudStackContextLoaderListener.class); CloudStackSpringContext cloudStackContext; String configuredParentName; diff --git a/packaging/centos7/cloud.spec b/packaging/centos7/cloud.spec index 8b26086f6eb..5133bbd31ca 100644 --- a/packaging/centos7/cloud.spec +++ b/packaging/centos7/cloud.spec @@ -261,7 +261,7 @@ cp client/target/lib/*jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/lib/ rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/scripts rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/vms -for name in db.properties server.properties log4j-cloud.xml commons-logging.properties environment.properties java.security.ciphers +for name in db.properties server.properties log4j-cloud.xml environment.properties java.security.ciphers do cp client/target/conf/$name ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/$name done @@ -492,7 +492,6 @@ pip install --upgrade /usr/share/cloudstack-marvin/Marvin-*.tar.gz %config(noreplace) %{_sysconfdir}/%{name}/management/log4j.xml %config(noreplace) %{_sysconfdir}/%{name}/management/environment.properties %config(noreplace) %{_sysconfdir}/%{name}/management/java.security.ciphers -%config(noreplace) %{_sysconfdir}/%{name}/management/commons-logging.properties %attr(0644,root,root) %{_unitdir}/%{name}-management.service %attr(0755,cloud,cloud) %{_localstatedir}/run/%{name}-management.pid %attr(0755,root,root) %{_bindir}/%{name}-setup-management diff --git a/pom.xml b/pom.xml index da9abcb8fe7..8760aab3b4f 100644 --- a/pom.xml +++ b/pom.xml @@ -170,7 +170,6 @@ 6.2.0-3.1 3.1.3 1.4.11.1 - 1.7.29 5.2.3.RELEASE @@ -627,16 +626,6 @@ reflections ${cs.reflections.version} - - org.slf4j - slf4j-api - ${cs.slf4j.version} - - - org.slf4j - slf4j-log4j12 - ${cs.slf4j.version} - org.springframework spring-aop diff --git a/usage/pom.xml b/usage/pom.xml index d3b83f6cbc2..119f47d9d0b 100644 --- a/usage/pom.xml +++ b/usage/pom.xml @@ -63,14 +63,6 @@ mysql-connector-java provided - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-log4j12 - org.dbunit dbunit diff --git a/utils/pom.xml b/utils/pom.xml index 163232e8062..8a745aa21a7 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -50,14 +50,6 @@ log4j log4j - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-log4j12 - cglib cglib-nodep diff --git a/utils/src/main/java/com/cloud/utils/backoff/impl/ConstantTimeBackoff.java b/utils/src/main/java/com/cloud/utils/backoff/impl/ConstantTimeBackoff.java index ace3b442286..c48f4462a52 100644 --- a/utils/src/main/java/com/cloud/utils/backoff/impl/ConstantTimeBackoff.java +++ b/utils/src/main/java/com/cloud/utils/backoff/impl/ConstantTimeBackoff.java @@ -23,13 +23,10 @@ import java.util.Collection; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import com.cloud.utils.NumbersUtil; import com.cloud.utils.backoff.BackoffAlgorithm; import com.cloud.utils.component.AdapterBase; +import org.apache.log4j.Logger; /** * An implementation of BackoffAlgorithm that waits for some seconds. @@ -44,7 +41,7 @@ import com.cloud.utils.component.AdapterBase; public class ConstantTimeBackoff extends AdapterBase implements BackoffAlgorithm, ConstantTimeBackoffMBean { long _time; private final Map _asleep = new ConcurrentHashMap(); - private final static Log LOG = LogFactory.getLog(ConstantTimeBackoff.class); + private static final Logger LOG = Logger.getLogger(ConstantTimeBackoff.class.getName()); @Override public void waitBeforeRetry() { diff --git a/utils/src/main/java/com/cloud/utils/xmlobject/XmlObject.java b/utils/src/main/java/com/cloud/utils/xmlobject/XmlObject.java index 42af9455abb..b3b5bd1a32d 100644 --- a/utils/src/main/java/com/cloud/utils/xmlobject/XmlObject.java +++ b/utils/src/main/java/com/cloud/utils/xmlobject/XmlObject.java @@ -27,7 +27,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.logging.Logger; +import org.apache.log4j.Logger; import com.cloud.utils.exception.CloudRuntimeException; diff --git a/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java b/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java index 5ff58190daa..9a4a6956f8a 100644 --- a/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java +++ b/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java @@ -24,8 +24,7 @@ import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.HttpClientError; import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.log4j.Logger; import javax.net.SocketFactory; import javax.net.ssl.SSLContext; @@ -88,7 +87,7 @@ import java.net.UnknownHostException; public class EasySSLProtocolSocketFactory implements ProtocolSocketFactory { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(EasySSLProtocolSocketFactory.class); + private static final Logger LOG = Logger.getLogger(EasySSLProtocolSocketFactory.class.getName()); private SSLContext sslcontext = null; diff --git a/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java b/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java index eb23eb29b92..321d28718ac 100644 --- a/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java +++ b/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java @@ -29,8 +29,7 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.log4j.Logger; /** *

@@ -58,7 +57,7 @@ public class EasyX509TrustManager implements X509TrustManager { private X509TrustManager standardTrustManager = null; /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(EasyX509TrustManager.class); + private static final Logger LOG = Logger.getLogger(EasyX509TrustManager.class.getName()); /** * Constructor for EasyX509TrustManager. @@ -83,7 +82,7 @@ public class EasyX509TrustManager implements X509TrustManager { } /** - * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String authType) + * @see X509TrustManager#checkServerTrusted(X509Certificate[],String authType) */ @Override public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException { diff --git a/utils/src/test/java/com/cloud/utils/backoff/impl/ConstantTimeBackoffTest.java b/utils/src/test/java/com/cloud/utils/backoff/impl/ConstantTimeBackoffTest.java index d39751112be..e1b029ee8d5 100644 --- a/utils/src/test/java/com/cloud/utils/backoff/impl/ConstantTimeBackoffTest.java +++ b/utils/src/test/java/com/cloud/utils/backoff/impl/ConstantTimeBackoffTest.java @@ -21,13 +21,12 @@ package com.cloud.utils.backoff.impl; import java.util.HashMap; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.log4j.Logger; import org.junit.Assert; import org.junit.Test; public class ConstantTimeBackoffTest { - final static private Log LOG = LogFactory.getLog(ConstantTimeBackoffTest.class); + private static final Logger LOG = Logger.getLogger(ConstantTimeBackoffTest.class.getName()); @Test public void waitBeforeRetryWithInterrupt() throws InterruptedException {