mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	CLOUDSTACK-1267: Configure log4j in proper place so that it can be initialized correctly in KVM and system VM environment
This commit is contained in:
		
							parent
							
								
									9f7b82281d
								
							
						
					
					
						commit
						c235d029ce
					
				@ -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) {
 | 
			
		||||
 | 
			
		||||
@ -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());
 | 
			
		||||
	        }
 | 
			
		||||
	    }
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user