agent: Log4j should not be initialized in the main method Since we use JSVC we don't execute the main method, but it is still there for manually running the Agent.
Initializing log4j in the start method makes sure it also works with JSVC Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/a4521551 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/a4521551 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/a4521551 Branch: refs/heads/gslb-wip Commit: a4521551a35cadd19a95752d3d93af8c2a9edd5b Parents: a1ca7e0 Author: Wido den Hollander <w...@widodh.nl> Authored: Wed Mar 6 16:41:39 2013 +0100 Committer: Wido den Hollander <w...@widodh.nl> Committed: Wed Mar 6 16:42:38 2013 +0100 ---------------------------------------------------------------------- agent/src/com/cloud/agent/AgentShell.java | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a4521551/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 7297ab2..9cb3c3d 100644 --- a/agent/src/com/cloud/agent/AgentShell.java +++ b/agent/src/com/cloud/agent/AgentShell.java @@ -553,6 +553,9 @@ public class AgentShell implements IAgentShell { public void start() { try { + /* By default we only search for log4j.xml */ + LogUtils.initLog4j("log4j-cloud.xml"); + System.setProperty("java.net.preferIPv4Stack", "true"); String instance = getProperty(null, "instance"); @@ -612,8 +615,6 @@ public class AgentShell implements IAgentShell { public static void main(String[] args) { try { - LogUtils.initLog4j("log4j-cloud.xml"); - AgentShell shell = new AgentShell(); shell.init(args); shell.start();