From a4521551a35cadd19a95752d3d93af8c2a9edd5b Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Wed, 6 Mar 2013 16:41:39 +0100 Subject: [PATCH] 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 --- agent/src/com/cloud/agent/AgentShell.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/agent/src/com/cloud/agent/AgentShell.java b/agent/src/com/cloud/agent/AgentShell.java index 7297ab285e5..9cb3c3db3ff 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();