Return-Path: X-Original-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 346CCE74B for ; Wed, 13 Mar 2013 17:14:08 +0000 (UTC) Received: (qmail 32382 invoked by uid 500); 13 Mar 2013 17:13:58 -0000 Delivered-To: apmail-incubator-cloudstack-commits-archive@incubator.apache.org Received: (qmail 32305 invoked by uid 500); 13 Mar 2013 17:13:58 -0000 Mailing-List: contact cloudstack-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-commits@incubator.apache.org Received: (qmail 31460 invoked by uid 99); 13 Mar 2013 17:13:57 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Mar 2013 17:13:57 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 0DB6DDE26; Wed, 13 Mar 2013 17:13:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bfederle@apache.org To: cloudstack-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [7/35] git commit: refs/heads/ui-multiple-nics - CLOUDSTACK-1267: Configure log4j in proper place so that it can be initialized correctly in KVM and system VM environment Message-Id: <20130313171357.0DB6DDE26@tyr.zones.apache.org> Date: Wed, 13 Mar 2013 17:13:57 +0000 (UTC) CLOUDSTACK-1267: Configure log4j in proper place so that it can be initialized correctly in KVM and system VM environment Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/c235d029 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/c235d029 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/c235d029 Branch: refs/heads/ui-multiple-nics Commit: c235d029ce1ae22f7e7b041bc2b36ac63368f38e Parents: 9f7b822 Author: Kelven Yang Authored: Mon Mar 11 19:06:12 2013 -0700 Committer: Kelven Yang Committed: Mon Mar 11 19:13:32 2013 -0700 ---------------------------------------------------------------------- agent/src/com/cloud/agent/AgentShell.java | 15 +++++++++++++++ utils/src/com/cloud/utils/LogUtils.java | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c235d029/agent/src/com/cloud/agent/AgentShell.java ---------------------------------------------------------------------- diff --git a/agent/src/com/cloud/agent/AgentShell.java b/agent/src/com/cloud/agent/AgentShell.java index 9cb3c3d..2af08e9 100644 --- a/agent/src/com/cloud/agent/AgentShell.java +++ b/agent/src/com/cloud/agent/AgentShell.java @@ -38,10 +38,13 @@ import java.util.UUID; import javax.naming.ConfigurationException; +import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; +import org.apache.log4j.xml.DOMConfigurator; import com.cloud.agent.Agent.ExitStatus; import com.cloud.agent.dao.StorageComponent; @@ -377,6 +380,18 @@ public class AgentShell implements IAgentShell { public void init(String[] args) throws ConfigurationException { + // PropertiesUtil is used both in management server and agent packages, + // it searches path under class path and common J2EE containers + // For KVM agent, do it specially here + + File file = new File("/etc/cloudstack/agent/log4j-cloud.xml"); + if(file == null || !file.exists()) { + file = PropertiesUtil.findConfigFile("log4j-cloud.xml"); + } + DOMConfigurator.configureAndWatch(file.getAbsolutePath()); + + s_logger.info("Agent started"); + final Class c = this.getClass(); _version = c.getPackage().getImplementationVersion(); if (_version == null) { http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c235d029/utils/src/com/cloud/utils/LogUtils.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/LogUtils.java b/utils/src/com/cloud/utils/LogUtils.java index 975de83..19c4c0e 100644 --- a/utils/src/com/cloud/utils/LogUtils.java +++ b/utils/src/com/cloud/utils/LogUtils.java @@ -19,7 +19,6 @@ package com.cloud.utils; import java.io.File; import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.xml.DOMConfigurator; public class LogUtils { @@ -36,7 +35,7 @@ public class LogUtils { file = PropertiesUtil.findConfigFile(nameWithoutExtension + ".properties"); if (file != null) { s_logger.info("log4j configuration found at " + file.getAbsolutePath()); - PropertyConfigurator.configureAndWatch(file.getAbsolutePath()); + DOMConfigurator.configureAndWatch(file.getAbsolutePath()); } } }