diff --git a/client/conf/log4j-cloud.xml.in b/client/conf/log4j-cloud.xml.in index 223692881dea..a61272bd8f7b 100755 --- a/client/conf/log4j-cloud.xml.in +++ b/client/conf/log4j-cloud.xml.in @@ -20,7 +20,7 @@ under the License. - + diff --git a/utils/src/main/java/com/cloud/utils/AutoCloseableUtil.java b/utils/src/main/java/com/cloud/utils/AutoCloseableUtil.java index f93265b5d64e..4cf9eb191ef2 100644 --- a/utils/src/main/java/com/cloud/utils/AutoCloseableUtil.java +++ b/utils/src/main/java/com/cloud/utils/AutoCloseableUtil.java @@ -16,10 +16,11 @@ // under the License. package com.cloud.utils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; public class AutoCloseableUtil { - private final static Logger s_logger = Logger.getLogger(AutoCloseableUtil.class); + private final static Logger LOG = LogFactory.getLogger(AutoCloseableUtil.class); public static void closeAutoCloseable(AutoCloseable ac, String message) { try { @@ -29,7 +30,7 @@ public static void closeAutoCloseable(AutoCloseable ac, String message) { } } catch (Exception e) { - s_logger.warn("[ignored] " + message, e); + LOG.warn("[ignored] " + message, e); } } diff --git a/utils/src/main/java/com/cloud/utils/EncryptionUtil.java b/utils/src/main/java/com/cloud/utils/EncryptionUtil.java index b82842e947b6..e86f27cce7c3 100644 --- a/utils/src/main/java/com/cloud/utils/EncryptionUtil.java +++ b/utils/src/main/java/com/cloud/utils/EncryptionUtil.java @@ -26,14 +26,15 @@ import javax.crypto.spec.SecretKeySpec; import org.apache.commons.codec.binary.Base64; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.jasypt.encryption.pbe.PBEStringEncryptor; import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; import com.cloud.utils.exception.CloudRuntimeException; public class EncryptionUtil { - public static final Logger s_logger = Logger.getLogger(EncryptionUtil.class.getName()); + public static final Logger LOG = LogFactory.getLogger(EncryptionUtil.class); private static PBEStringEncryptor encryptor; private static void initialize(String key) { @@ -66,7 +67,7 @@ public static String generateSignature(String data, String key) { final byte[] encryptedBytes = mac.doFinal(); return Base64.encodeBase64String(encryptedBytes); } catch (NoSuchAlgorithmException | InvalidKeyException | UnsupportedEncodingException e) { - s_logger.error("exception occurred which encoding the data." + e.getMessage()); + LOG.error("exception occurred which encoding the data." + e.getMessage()); throw new CloudRuntimeException("unable to generate signature", e); } } diff --git a/utils/src/main/java/com/cloud/utils/HttpUtils.java b/utils/src/main/java/com/cloud/utils/HttpUtils.java index a5d9f6a16b67..e7550fd03a29 100644 --- a/utils/src/main/java/com/cloud/utils/HttpUtils.java +++ b/utils/src/main/java/com/cloud/utils/HttpUtils.java @@ -19,7 +19,8 @@ package com.cloud.utils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; @@ -29,7 +30,7 @@ public class HttpUtils { - public static final Logger s_logger = Logger.getLogger(HttpUtils.class); + public static final Logger LOG = LogFactory.getLogger(HttpUtils.class); public static final String UTF_8 = "UTF-8"; public static final String RESPONSE_TYPE_JSON = "json"; @@ -81,12 +82,12 @@ public static void writeHttpResponse(final HttpServletResponse resp, final Strin addSecurityHeaders(resp); resp.getWriter().print(response); } catch (final IOException ioex) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Exception writing http response: " + ioex); + if (LOG.isTraceEnabled()) { + LOG.trace("Exception writing http response: " + ioex); } } catch (final Exception ex) { if (!(ex instanceof IllegalStateException)) { - s_logger.error("Unknown exception writing http response", ex); + LOG.error("Unknown exception writing http response", ex); } } } diff --git a/utils/src/main/java/com/cloud/utils/Journal.java b/utils/src/main/java/com/cloud/utils/Journal.java index e88dba39ff2e..b5bf472aafce 100644 --- a/utils/src/main/java/com/cloud/utils/Journal.java +++ b/utils/src/main/java/com/cloud/utils/Journal.java @@ -21,8 +21,8 @@ import java.util.ArrayList; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Level; +import org.apache.cloudstack.utils.log.Logger; /** * Journal is used to kept what has happened during a process so someone can track @@ -91,6 +91,10 @@ public String toString() { public static class LogJournal extends Journal { Logger _logger; + @Deprecated + public LogJournal(String name, org.apache.log4j.Logger logger) { + this(name, new Logger(logger)); + } public LogJournal(String name, Logger logger) { super(name); _logger = logger; @@ -98,7 +102,7 @@ public LogJournal(String name, Logger logger) { @Override public void record(String msg, Object... params) { - record(_logger, Level.DEBUG, msg, params); + record(_logger, (org.apache.cloudstack.utils.log.Level)Level.DEBUG, msg, params); } } } diff --git a/utils/src/main/java/com/cloud/utils/LogUtils.java b/utils/src/main/java/com/cloud/utils/LogUtils.java index d86766ccc022..b8827d25a03f 100644 --- a/utils/src/main/java/com/cloud/utils/LogUtils.java +++ b/utils/src/main/java/com/cloud/utils/LogUtils.java @@ -21,23 +21,24 @@ import java.io.File; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.apache.log4j.xml.DOMConfigurator; public class LogUtils { - public static final Logger s_logger = Logger.getLogger(LogUtils.class); + public static final Logger LOG = LogFactory.getLogger(LogUtils.class); public static void initLog4j(String log4jConfigFileName) { assert (log4jConfigFileName != null); File file = PropertiesUtil.findConfigFile(log4jConfigFileName); if (file != null) { - s_logger.info("log4j configuration found at " + file.getAbsolutePath()); + LOG.info("log4j configuration found at " + file.getAbsolutePath()); DOMConfigurator.configureAndWatch(file.getAbsolutePath()); } else { String nameWithoutExtension = log4jConfigFileName.substring(0, log4jConfigFileName.lastIndexOf('.')); file = PropertiesUtil.findConfigFile(nameWithoutExtension + ".properties"); if (file != null) { - s_logger.info("log4j configuration found at " + file.getAbsolutePath()); + LOG.info("log4j configuration found at " + file.getAbsolutePath()); DOMConfigurator.configureAndWatch(file.getAbsolutePath()); } } diff --git a/utils/src/main/java/com/cloud/utils/ProcessUtil.java b/utils/src/main/java/com/cloud/utils/ProcessUtil.java index 53137c4e3930..fb07a2bef0fb 100644 --- a/utils/src/main/java/com/cloud/utils/ProcessUtil.java +++ b/utils/src/main/java/com/cloud/utils/ProcessUtil.java @@ -26,14 +26,15 @@ import javax.naming.ConfigurationException; import org.apache.commons.io.FileUtils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.OutputInterpreter; import com.cloud.utils.script.Script; public class ProcessUtil { - private static final Logger s_logger = Logger.getLogger(ProcessUtil.class.getName()); + private static final Logger LOG = LogFactory.getLogger(ProcessUtil.class); // paths cannot be hardcoded public static void pidCheck(String pidDir, String run) throws ConfigurationException { @@ -43,7 +44,7 @@ public static void pidCheck(String pidDir, String run) throws ConfigurationExcep try { final File propsFile = PropertiesUtil.findConfigFile("environment.properties"); if (propsFile == null) { - s_logger.debug("environment.properties could not be opened"); + LOG.debug("environment.properties could not be opened"); } else { final Properties props = PropertiesUtil.loadFromFile(propsFile); dir = props.getProperty("paths.pid"); @@ -52,7 +53,7 @@ public static void pidCheck(String pidDir, String run) throws ConfigurationExcep } } } catch (IOException e) { - s_logger.debug("environment.properties could not be opened"); + LOG.debug("environment.properties could not be opened"); } final File pidFile = new File(dir + File.separator + run); @@ -68,7 +69,7 @@ public static void pidCheck(String pidDir, String run) throws ConfigurationExcep } try { final long pid = Long.parseLong(pidLine); - final Script script = new Script("bash", 120000, s_logger); + final Script script = new Script("bash", 120000, LOG); script.add("-c", "ps -p " + pid); final String result = script.execute(); if (result == null) { @@ -86,7 +87,7 @@ public static void pidCheck(String pidDir, String run) throws ConfigurationExcep } pidFile.deleteOnExit(); - final Script script = new Script("bash", 120000, s_logger); + final Script script = new Script("bash", 120000, LOG); script.add("-c", "echo $PPID"); final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); script.execute(parser); diff --git a/utils/src/main/java/com/cloud/utils/Profiler.java b/utils/src/main/java/com/cloud/utils/Profiler.java index addee2db200b..f2d77d1ea886 100644 --- a/utils/src/main/java/com/cloud/utils/Profiler.java +++ b/utils/src/main/java/com/cloud/utils/Profiler.java @@ -85,4 +85,4 @@ public String toString() { return "Done. Duration: " + getDurationInMillis() + "ms"; } -} \ No newline at end of file +} diff --git a/utils/src/main/java/com/cloud/utils/PropertiesUtil.java b/utils/src/main/java/com/cloud/utils/PropertiesUtil.java index 4cb89f7531d6..5a13210ef10f 100644 --- a/utils/src/main/java/com/cloud/utils/PropertiesUtil.java +++ b/utils/src/main/java/com/cloud/utils/PropertiesUtil.java @@ -29,10 +29,11 @@ import java.util.Properties; import java.util.Set; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; public class PropertiesUtil { - private static final Logger s_logger = Logger.getLogger(PropertiesUtil.class); + private static final Logger LOG = LogFactory.getLogger(PropertiesUtil.class); /** * Searches the class path and local paths to find the config file. @@ -129,7 +130,7 @@ public static void loadFromJar(Properties properties, String configFile) throws if (stream != null) { properties.load(stream); } else { - s_logger.error("Unable to find properties file: " + configFile); + LOG.error("Unable to find properties file: " + configFile); } } @@ -144,7 +145,7 @@ public static Map processConfigFile(String[] configFiles) { try { loadFromFile(preProcessedCommands, commandsFile); } catch (IOException ioe) { - s_logger.error("IO Exception loading properties file", ioe); + LOG.error("IO Exception loading properties file", ioe); } } else { @@ -152,7 +153,7 @@ public static Map processConfigFile(String[] configFiles) { try { loadFromJar(preProcessedCommands, configFile); } catch (IOException e) { - s_logger.error("IO Exception loading properties file from jar", e); + LOG.error("IO Exception loading properties file from jar", e); } } } diff --git a/utils/src/main/java/com/cloud/utils/ReflectUtil.java b/utils/src/main/java/com/cloud/utils/ReflectUtil.java index 1d31093e0c86..08c8bc884137 100644 --- a/utils/src/main/java/com/cloud/utils/ReflectUtil.java +++ b/utils/src/main/java/com/cloud/utils/ReflectUtil.java @@ -37,7 +37,8 @@ import java.util.List; import java.util.Set; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.reflections.Reflections; import org.reflections.util.ConfigurationBuilder; import org.reflections.util.ClasspathHelper; @@ -50,8 +51,8 @@ public class ReflectUtil { - private static final Logger s_logger = Logger.getLogger(ReflectUtil.class); - private static final Logger logger = Logger.getLogger(Reflections.class); + private static final Logger LOG = LogFactory.getLogger(ReflectUtil.class); + private static final Logger logger = LogFactory.getLogger(Reflections.class); public static Pair, Field> getAnyField(Class clazz, String fieldName) { try { @@ -186,13 +187,13 @@ private static List flattenProperties(final Object target, final Class searchUrls = new ArrayList<>(); for (final URL url: urls) { if (url.toString().contains(name)) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Search URL: " + url.toString()); + if (LOG.isDebugEnabled()) { + LOG.debug("Search URL: " + url.toString()); } searchUrls.add(url); } diff --git a/utils/src/main/java/com/cloud/utils/SwiftUtil.java b/utils/src/main/java/com/cloud/utils/SwiftUtil.java index 34aceb51553e..b61625229977 100644 --- a/utils/src/main/java/com/cloud/utils/SwiftUtil.java +++ b/utils/src/main/java/com/cloud/utils/SwiftUtil.java @@ -32,14 +32,15 @@ import javax.crypto.spec.SecretKeySpec; import org.apache.commons.codec.binary.Hex; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.OutputInterpreter; import com.cloud.utils.script.Script; public class SwiftUtil { - private static Logger logger = Logger.getLogger(SwiftUtil.class); + private static Logger logger = LogFactory.getLogger(SwiftUtil.class); protected static final long SWIFT_MAX_SIZE = 5L * 1024L * 1024L * 1024L; private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1"; private static final String CD_SRC = "cd %s;"; @@ -309,4 +310,4 @@ private static String getMeta(Map metas) { } return cms.toString(); } -} \ No newline at end of file +} diff --git a/utils/src/main/java/com/cloud/utils/UriUtils.java b/utils/src/main/java/com/cloud/utils/UriUtils.java index b3ec4643fb1d..16385aea5d76 100644 --- a/utils/src/main/java/com/cloud/utils/UriUtils.java +++ b/utils/src/main/java/com/cloud/utils/UriUtils.java @@ -55,7 +55,8 @@ import org.apache.http.client.utils.URLEncodedUtils; import org.apache.http.message.BasicNameValuePair; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.cloud.utils.crypt.DBEncryptionUtil; import com.cloud.utils.exception.CloudRuntimeException; @@ -68,7 +69,7 @@ public class UriUtils { - public static final Logger s_logger = Logger.getLogger(UriUtils.class.getName()); + public static final Logger LOG = LogFactory.getLogger(UriUtils.class); public static String formNfsUri(String host, String path) { try { @@ -125,7 +126,7 @@ public static String encodeURIComponent(String url) { public static String getCifsUriParametersProblems(URI uri) { if (!UriUtils.hostAndPathPresent(uri)) { String errMsg = "cifs URI missing host and/or path. Make sure it's of the format cifs://hostname/path"; - s_logger.warn(errMsg); + LOG.warn(errMsg); return errMsg; } return null; @@ -143,10 +144,10 @@ public static boolean cifsCredentialsPresent(URI uri) { String name = nvp.getName(); if (name.equals("user")) { foundUser = true; - s_logger.debug("foundUser is" + foundUser); + LOG.debug("foundUser is" + foundUser); } else if (name.equals("password")) { foundPswd = true; - s_logger.debug("foundPswd is" + foundPswd); + LOG.debug("foundPswd is" + foundPswd); } } return (foundUser && foundPswd); @@ -377,7 +378,7 @@ protected static Map> getMultipleValuesFromXML(InputStream for (int i = 0; i < tagNames.length; i++) { NodeList targetNodes = rootElement.getElementsByTagName(tagNames[i]); if (targetNodes.getLength() <= 0) { - s_logger.error("no " + tagNames[i] + " tag in XML response..."); + LOG.error("no " + tagNames[i] + " tag in XML response..."); } else { List> priorityList = new ArrayList<>(); for (int j = 0; j < targetNodes.getLength(); j++) { @@ -389,7 +390,7 @@ protected static Map> getMultipleValuesFromXML(InputStream } } } catch (Exception ex) { - s_logger.error(ex); + LOG.error(ex.getLocalizedMessage()); } return returnValues; } @@ -419,14 +420,14 @@ protected static boolean checkUrlExistenceMetalink(String url) { break; } catch (IllegalArgumentException e) { - s_logger.warn(e.getMessage()); + LOG.warn(e.getMessage()); } } return validUrl; } } } catch (IOException e) { - s_logger.warn(e.getMessage()); + LOG.warn(e.getMessage()); } finally { getMethod.releaseConnection(); } @@ -444,7 +445,7 @@ public static List getMetalinkUrls(String metalinkUrl) { try { status = httpClient.executeMethod(getMethod); } catch (IOException e) { - s_logger.error("Error retrieving urls form metalink: " + metalinkUrl); + LOG.error("Error retrieving urls form metalink: " + metalinkUrl); getMethod.releaseConnection(); return null; } @@ -458,7 +459,7 @@ public static List getMetalinkUrls(String metalinkUrl) { } } } catch (IOException e) { - s_logger.warn(e.getMessage()); + LOG.warn(e.getMessage()); } finally { getMethod.releaseConnection(); } @@ -567,20 +568,20 @@ public static InputStream getInputStreamFromUrl(String url, String user, String httpclient.getParams().setAuthenticationPreemptive(true); Credentials defaultcreds = new UsernamePasswordCredentials(user, password); httpclient.getState().setCredentials(new AuthScope(hostAndPort.first(), hostAndPort.second(), AuthScope.ANY_REALM), defaultcreds); - s_logger.info("Added username=" + user + ", password=" + password + "for host " + hostAndPort.first() + ":" + hostAndPort.second()); + LOG.info("Added username=" + user + ", password=" + password + "for host " + hostAndPort.first() + ":" + hostAndPort.second()); } // Execute the method. GetMethod method = new GetMethod(url); int statusCode = httpclient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { - s_logger.error("Failed to read from URL: " + url); + LOG.error("Failed to read from URL: " + url); return null; } return method.getResponseBodyAsStream(); } catch (Exception ex) { - s_logger.error("Failed to read from URL: " + url); + LOG.error("Failed to read from URL: " + url); return null; } } diff --git a/utils/src/main/java/com/cloud/utils/UuidUtils.java b/utils/src/main/java/com/cloud/utils/UuidUtils.java index 9c4a75633548..df16b61def35 100644 --- a/utils/src/main/java/com/cloud/utils/UuidUtils.java +++ b/utils/src/main/java/com/cloud/utils/UuidUtils.java @@ -31,4 +31,4 @@ public static boolean validateUUID(String uuid) { RegularExpression regex = new RegularExpression("[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}"); return regex.matches(uuid); } -} \ No newline at end of file +} 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 ace3b4422864..1f2a9f0ead33 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,11 @@ 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.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; /** * An implementation of BackoffAlgorithm that waits for some seconds. @@ -44,7 +42,7 @@ 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 final static Logger LOG = LogFactory.getLogger(ConstantTimeBackoff.class); @Override public void waitBeforeRetry() { diff --git a/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java index a6d905d8f8a4..53d32d845a3e 100644 --- a/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java +++ b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java @@ -23,7 +23,8 @@ import java.io.OutputStream; import java.util.List; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.trilead.ssh2.Connection; import com.trilead.ssh2.Session; @@ -36,7 +37,7 @@ import com.cloud.utils.ssh.SSHCmdHelper; public class NetconfHelper { - private static final Logger s_logger = Logger.getLogger(NetconfHelper.class); + private static final Logger LOG = LogFactory.getLogger(NetconfHelper.class); private static final String SSH_NETCONF_TERMINATOR = "]]>]]>"; @@ -56,7 +57,7 @@ public NetconfHelper(String ip, String username, String password) throws CloudRu exchangeHello(); } catch (final Exception e) { disconnect(); - s_logger.error("Failed to connect to device SSH server: " + e.getMessage()); + LOG.error("Failed to connect to device SSH server: " + e.getMessage()); throw new CloudRuntimeException("Failed to connect to SSH server: " + _connection.getHostname()); } } @@ -228,7 +229,7 @@ private void send(String message) { outputStream.write(message.getBytes()); outputStream.flush(); } catch (Exception e) { - s_logger.error("Failed to send message: " + e.getMessage()); + LOG.error("Failed to send message: " + e.getMessage()); throw new CloudRuntimeException("Failed to send message: " + e.getMessage()); } } diff --git a/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java index 447e21b81adc..9af6ddfc6f81 100644 --- a/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java +++ b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java @@ -25,7 +25,8 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.w3c.dom.DOMException; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; @@ -38,7 +39,7 @@ public class VsmCommand { - private static final Logger s_logger = Logger.getLogger(VsmCommand.class); + private static final Logger LOG = LogFactory.getLogger(VsmCommand.class); private static final String s_namespace = "urn:ietf:params:xml:ns:netconf:base:1.0"; private static final String s_ciscons = "http://www.cisco.com/nxos:1.0:ppm"; private static final String s_configuremode = "__XML__MODE__exec_configure"; @@ -88,10 +89,10 @@ public static String getAddPortProfile(String name, PortProfileType type, Bindin return serialize(domImpl, doc); } catch (ParserConfigurationException e) { - s_logger.error("Error while creating add port profile message : " + e.getMessage()); + LOG.error("Error while creating add port profile message : " + e.getMessage()); return null; } catch (DOMException e) { - s_logger.error("Error while creating add port profile message : " + e.getMessage()); + LOG.error("Error while creating add port profile message : " + e.getMessage()); return null; } } @@ -121,10 +122,10 @@ public static String getAddPortProfile(String name, PortProfileType type, Bindin return serialize(domImpl, doc); } catch (ParserConfigurationException e) { - s_logger.error("Error while creating add port profile message : " + e.getMessage()); + LOG.error("Error while creating add port profile message : " + e.getMessage()); return null; } catch (DOMException e) { - s_logger.error("Error while creating add port profile message : " + e.getMessage()); + LOG.error("Error while creating add port profile message : " + e.getMessage()); return null; } } @@ -154,10 +155,10 @@ public static String getUpdatePortProfile(String name, SwitchPortMode mode, List return serialize(domImpl, doc); } catch (ParserConfigurationException e) { - s_logger.error("Error while creating update port profile message : " + e.getMessage()); + LOG.error("Error while creating update port profile message : " + e.getMessage()); return null; } catch (DOMException e) { - s_logger.error("Error while creating update port profile message : " + e.getMessage()); + LOG.error("Error while creating update port profile message : " + e.getMessage()); return null; } } @@ -187,10 +188,10 @@ public static String getDeletePortProfile(String portName) { return serialize(domImpl, doc); } catch (ParserConfigurationException e) { - s_logger.error("Error while creating delete port profile message : " + e.getMessage()); + LOG.error("Error while creating delete port profile message : " + e.getMessage()); return null; } catch (DOMException e) { - s_logger.error("Error while creating delete port profile message : " + e.getMessage()); + LOG.error("Error while creating delete port profile message : " + e.getMessage()); return null; } } @@ -220,10 +221,10 @@ public static String getAddPolicyMap(String name, int averageRate, int maxRate, return serialize(domImpl, doc); } catch (ParserConfigurationException e) { - s_logger.error("Error while creating policy map message : " + e.getMessage()); + LOG.error("Error while creating policy map message : " + e.getMessage()); return null; } catch (DOMException e) { - s_logger.error("Error while creating policy map message : " + e.getMessage()); + LOG.error("Error while creating policy map message : " + e.getMessage()); return null; } } @@ -253,10 +254,10 @@ public static String getDeletePolicyMap(String name) { return serialize(domImpl, doc); } catch (ParserConfigurationException e) { - s_logger.error("Error while creating delete policy map message : " + e.getMessage()); + LOG.error("Error while creating delete policy map message : " + e.getMessage()); return null; } catch (DOMException e) { - s_logger.error("Error while creating delete policy map message : " + e.getMessage()); + LOG.error("Error while creating delete policy map message : " + e.getMessage()); return null; } } @@ -286,10 +287,10 @@ public static String getServicePolicy(String policyMap, String portProfile, bool return serialize(domImpl, doc); } catch (ParserConfigurationException e) { - s_logger.error("Error while creating attach/detach service policy message : " + e.getMessage()); + LOG.error("Error while creating attach/detach service policy message : " + e.getMessage()); return null; } catch (DOMException e) { - s_logger.error("Error while creating attach/detach service policy message : " + e.getMessage()); + LOG.error("Error while creating attach/detach service policy message : " + e.getMessage()); return null; } } @@ -323,10 +324,10 @@ public static String getPortProfile(String name) { return serialize(domImpl, doc); } catch (ParserConfigurationException e) { - s_logger.error("Error while creating the message to get port profile details: " + e.getMessage()); + LOG.error("Error while creating the message to get port profile details: " + e.getMessage()); return null; } catch (DOMException e) { - s_logger.error("Error while creating the message to get port profile details: " + e.getMessage()); + LOG.error("Error while creating the message to get port profile details: " + e.getMessage()); return null; } } @@ -356,10 +357,10 @@ public static String getPolicyMap(String name) { return serialize(domImpl, doc); } catch (ParserConfigurationException e) { - s_logger.error("Error while creating the message to get policy map details : " + e.getMessage()); + LOG.error("Error while creating the message to get policy map details : " + e.getMessage()); return null; } catch (DOMException e) { - s_logger.error("Error while creating the message to get policy map details : " + e.getMessage()); + LOG.error("Error while creating the message to get policy map details : " + e.getMessage()); return null; } } @@ -383,10 +384,10 @@ public static String getHello() { return serialize(domImpl, doc); } catch (ParserConfigurationException e) { - s_logger.error("Error while creating hello message : " + e.getMessage()); + LOG.error("Error while creating hello message : " + e.getMessage()); return null; } catch (DOMException e) { - s_logger.error("Error while creating hello message : " + e.getMessage()); + LOG.error("Error while creating hello message : " + e.getMessage()); return null; } } @@ -416,10 +417,10 @@ public static String getVServiceNode(String vlanId, String ipAddr) { return serialize(domImpl, doc); } catch (ParserConfigurationException e) { - s_logger.error("Error while adding vservice node for vlan " + vlanId + ", " + e.getMessage()); + LOG.error("Error while adding vservice node for vlan " + vlanId + ", " + e.getMessage()); return null; } catch (DOMException e) { - s_logger.error("Error while adding vservice node for vlan " + vlanId + ", " + e.getMessage()); + LOG.error("Error while adding vservice node for vlan " + vlanId + ", " + e.getMessage()); return null; } } diff --git a/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmPolicyMapResponse.java b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmPolicyMapResponse.java index c0ed6ee812fb..0a56ccb9040a 100644 --- a/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmPolicyMapResponse.java +++ b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmPolicyMapResponse.java @@ -19,14 +19,15 @@ package com.cloud.utils.cisco.n1kv.vsm; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.w3c.dom.DOMException; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class VsmPolicyMapResponse extends VsmResponse { - private static final Logger s_logger = Logger.getLogger(VsmPolicyMapResponse.class); + private static final Logger LOG = LogFactory.getLogger(VsmPolicyMapResponse.class); private static final String s_policyMapDetails = "__XML__OPT_Cmd_show_policy-map___readonly__"; private PolicyMap _policyMap = new PolicyMap(); @@ -78,7 +79,7 @@ protected void parseData(Node data) { } } } catch (DOMException e) { - s_logger.error("Error parsing the response : " + e.toString()); + LOG.error("Error parsing the response : " + e.toString()); } } } diff --git a/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmPortProfileResponse.java b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmPortProfileResponse.java index 0a3de1879dff..9c23d31b4d80 100644 --- a/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmPortProfileResponse.java +++ b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmPortProfileResponse.java @@ -21,7 +21,8 @@ import java.util.StringTokenizer; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.w3c.dom.DOMException; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -32,7 +33,7 @@ import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.SwitchPortMode; public class VsmPortProfileResponse extends VsmResponse { - private static final Logger s_logger = Logger.getLogger(VsmPortProfileResponse.class); + private static final Logger LOG = LogFactory.getLogger(VsmPortProfileResponse.class); private static final String s_portProfileDetails = "__XML__OPT_Cmd_show_port_profile___readonly__"; private PortProfile _portProfile = new PortProfile(); @@ -93,7 +94,7 @@ protected void parseData(Node data) { } } } catch (DOMException e) { - s_logger.error("Error parsing the response : " + e.toString()); + LOG.error("Error parsing the response : " + e.toString()); } } diff --git a/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmResponse.java b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmResponse.java index d82b0dcf9827..ee0a3aa25aaa 100644 --- a/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmResponse.java +++ b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmResponse.java @@ -26,7 +26,8 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -69,7 +70,7 @@ public enum ErrorSeverity { error, warning; } - private static final Logger s_logger = Logger.getLogger(VsmResponse.class); + private static final Logger LOG = LogFactory.getLogger(VsmResponse.class); protected String _xmlResponse; protected Document _docResponse; @@ -101,11 +102,11 @@ protected void initialize() { parse(_docResponse.getDocumentElement()); } } catch (ParserConfigurationException e) { - s_logger.error("Error parsing the response : " + e.toString()); + LOG.error("Error parsing the response : " + e.toString()); } catch (SAXException e) { - s_logger.error("Error parsing the response : " + e.toString()); + LOG.error("Error parsing the response : " + e.toString()); } catch (IOException e) { - s_logger.error("Error parsing the response : " + e.toString()); + LOG.error("Error parsing the response : " + e.toString()); } } @@ -157,7 +158,7 @@ protected void parseError(Node element) { } } } catch (DOMException e) { - s_logger.error("Error parsing the response : " + e.toString()); + LOG.error("Error parsing the response : " + e.toString()); } } @@ -216,7 +217,7 @@ protected void printResponse() { LSSerializer lss = ls.createLSSerializer(); System.out.println(lss.writeToString(_docResponse)); } catch (ParserConfigurationException e) { - s_logger.error("Error parsing the repsonse : " + e.toString()); + LOG.error("Error parsing the repsonse : " + e.toString()); } } } diff --git a/utils/src/main/java/com/cloud/utils/component/ComponentContext.java b/utils/src/main/java/com/cloud/utils/component/ComponentContext.java index 8948b2789ee1..f279cbd87fc1 100644 --- a/utils/src/main/java/com/cloud/utils/component/ComponentContext.java +++ b/utils/src/main/java/com/cloud/utils/component/ComponentContext.java @@ -29,7 +29,8 @@ import javax.management.NotCompliantMBeanException; import javax.naming.ConfigurationException; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; @@ -48,7 +49,7 @@ */ @SuppressWarnings("unchecked") public class ComponentContext implements ApplicationContextAware { - private static final Logger s_logger = Logger.getLogger(ComponentContext.class); + private static final Logger LOG = LogFactory.getLogger(ComponentContext.class); private static ApplicationContext s_appContext; private static Map, ApplicationContext> s_appContextDelegates; @@ -56,7 +57,7 @@ public class ComponentContext implements ApplicationContextAware { @Override public void setApplicationContext(ApplicationContext applicationContext) { - s_logger.info("Setup Spring Application context"); + LOG.info("Setup Spring Application context"); s_appContext = applicationContext; } @@ -90,11 +91,11 @@ public static void initComponentsLifeCycle() { // Run the SystemIntegrityCheckers first Map integrityCheckers = getApplicationContext().getBeansOfType(SystemIntegrityChecker.class); for (Entry entry : integrityCheckers.entrySet()) { - s_logger.info("Running SystemIntegrityChecker " + entry.getKey()); + LOG.info("Running SystemIntegrityChecker " + entry.getKey()); try { entry.getValue().check(); } catch (Throwable e) { - s_logger.error("System integrity check failed. Refuse to startup", e); + LOG.error("System integrity check failed. Refuse to startup", e); System.exit(1); } } @@ -105,17 +106,17 @@ public static void initComponentsLifeCycle() { for (Map.Entry entry : classifiedComponents[i].entrySet()) { ComponentLifecycle component = entry.getValue(); String implClassName = ComponentContext.getTargetClass(component).getName(); - s_logger.info("Configuring " + implClassName); + LOG.info("Configuring " + implClassName); if (avoidMap.containsKey(implClassName)) { - s_logger.info("Skip configuration of " + implClassName + " as it is already configured"); + LOG.info("Skip configuration of " + implClassName + " as it is already configured"); continue; } try { component.configure(component.getName(), component.getConfigParams()); } catch (ConfigurationException e) { - s_logger.error("Unhandled exception", e); + LOG.error("Unhandled exception", e); throw new RuntimeException("Unable to configure " + implClassName, e); } @@ -129,10 +130,10 @@ public static void initComponentsLifeCycle() { for (Map.Entry entry : classifiedComponents[i].entrySet()) { ComponentLifecycle component = entry.getValue(); String implClassName = ComponentContext.getTargetClass(component).getName(); - s_logger.info("Starting " + implClassName); + LOG.info("Starting " + implClassName); if (avoidMap.containsKey(implClassName)) { - s_logger.info("Skip configuration of " + implClassName + " as it is already configured"); + LOG.info("Skip configuration of " + implClassName + " as it is already configured"); continue; } @@ -142,7 +143,7 @@ public static void initComponentsLifeCycle() { if (getTargetObject(component) instanceof ManagementBean) registerMBean((ManagementBean)getTargetObject(component)); } catch (Exception e) { - s_logger.error("Unhandled exception", e); + LOG.error("Unhandled exception", e); throw new RuntimeException("Unable to start " + implClassName, e); } @@ -155,15 +156,15 @@ static void registerMBean(ManagementBean mbean) { try { JmxUtil.registerMBean(mbean); } catch (MalformedObjectNameException e) { - s_logger.warn("Unable to register MBean: " + mbean.getName(), e); + LOG.warn("Unable to register MBean: " + mbean.getName(), e); } catch (InstanceAlreadyExistsException e) { - s_logger.warn("Unable to register MBean: " + mbean.getName(), e); + LOG.warn("Unable to register MBean: " + mbean.getName(), e); } catch (MBeanRegistrationException e) { - s_logger.warn("Unable to register MBean: " + mbean.getName(), e); + LOG.warn("Unable to register MBean: " + mbean.getName(), e); } catch (NotCompliantMBeanException e) { - s_logger.warn("Unable to register MBean: " + mbean.getName(), e); + LOG.warn("Unable to register MBean: " + mbean.getName(), e); } - s_logger.info("Registered MBean: " + mbean.getName()); + LOG.info("Registered MBean: " + mbean.getName()); } public static T getComponent(String name) { @@ -182,9 +183,9 @@ public static T getComponent(Class beanType) { } if (matchedTypes.size() > 1) { - s_logger.warn("Unable to uniquely locate bean type " + beanType.getName()); + LOG.warn("Unable to uniquely locate bean type " + beanType.getName()); for (Map.Entry entry : matchedTypes.entrySet()) { - s_logger.warn("Candidate " + getTargetClass(entry.getValue()).getName()); + LOG.warn("Candidate " + getTargetClass(entry.getValue()).getName()); } } @@ -227,10 +228,10 @@ public static T inject(Class clz) { instance = clz.newInstance(); return inject(instance); } catch (InstantiationException e) { - s_logger.error("Unhandled InstantiationException", e); + LOG.error("Unhandled InstantiationException", e); throw new RuntimeException("Unable to instantiate object of class " + clz.getName() + ", make sure it has public constructor"); } catch (IllegalAccessException e) { - s_logger.error("Unhandled IllegalAccessException", e); + LOG.error("Unhandled IllegalAccessException", e); throw new RuntimeException("Unable to instantiate object of class " + clz.getName() + ", make sure it has public constructor"); } } diff --git a/utils/src/main/java/com/cloud/utils/component/ComponentInstantiationPostProcessor.java b/utils/src/main/java/com/cloud/utils/component/ComponentInstantiationPostProcessor.java index 670437106272..89a0b49946bc 100644 --- a/utils/src/main/java/com/cloud/utils/component/ComponentInstantiationPostProcessor.java +++ b/utils/src/main/java/com/cloud/utils/component/ComponentInstantiationPostProcessor.java @@ -31,7 +31,8 @@ import net.sf.cglib.proxy.MethodProxy; import net.sf.cglib.proxy.NoOp; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.springframework.beans.BeansException; import org.springframework.beans.PropertyValues; import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor; @@ -39,7 +40,7 @@ import com.cloud.utils.Pair; public class ComponentInstantiationPostProcessor implements InstantiationAwareBeanPostProcessor { - private static final Logger s_logger = Logger.getLogger(ComponentInstantiationPostProcessor.class); + private static final Logger LOG = LogFactory.getLogger(ComponentInstantiationPostProcessor.class); private List _interceptors = new ArrayList(); private Callback[] _callbacks; diff --git a/utils/src/main/java/com/cloud/utils/component/ComponentLifecycleBase.java b/utils/src/main/java/com/cloud/utils/component/ComponentLifecycleBase.java index 829dc9b9e848..f8ae97c721f0 100644 --- a/utils/src/main/java/com/cloud/utils/component/ComponentLifecycleBase.java +++ b/utils/src/main/java/com/cloud/utils/component/ComponentLifecycleBase.java @@ -24,10 +24,11 @@ import javax.naming.ConfigurationException; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; public class ComponentLifecycleBase implements ComponentLifecycle { - private static final Logger s_logger = Logger.getLogger(ComponentLifecycleBase.class); + private static final Logger LOG = LogFactory.getLogger(ComponentLifecycleBase.class); protected String _name; protected int _runLevel; diff --git a/utils/src/main/java/com/cloud/utils/concurrency/SynchronizationEvent.java b/utils/src/main/java/com/cloud/utils/concurrency/SynchronizationEvent.java index 5207ad4d7897..0105dc4e92e6 100644 --- a/utils/src/main/java/com/cloud/utils/concurrency/SynchronizationEvent.java +++ b/utils/src/main/java/com/cloud/utils/concurrency/SynchronizationEvent.java @@ -19,10 +19,11 @@ package com.cloud.utils.concurrency; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; public class SynchronizationEvent { - protected final static Logger s_logger = Logger.getLogger(SynchronizationEvent.class); + protected final static Logger LOG = LogFactory.getLogger(SynchronizationEvent.class); private boolean signalled; @@ -58,7 +59,7 @@ public boolean waitEvent() throws InterruptedException { assert (signalled); return signalled; } catch (InterruptedException e) { - s_logger.debug("unexpected awaken signal in wait()"); + LOG.debug("unexpected awaken signal in wait()"); throw e; } } @@ -75,7 +76,7 @@ public boolean waitEvent(long timeOutMiliseconds) throws InterruptedException { return signalled; } catch (InterruptedException e) { // TODO, we don't honor time out semantics when the waiting thread is interrupted - s_logger.debug("unexpected awaken signal in wait(...)"); + LOG.debug("unexpected awaken signal in wait(...)"); throw e; } } diff --git a/utils/src/main/java/com/cloud/utils/crypt/DBEncryptionUtil.java b/utils/src/main/java/com/cloud/utils/crypt/DBEncryptionUtil.java index 52f2034c0ac1..81fcb4d32234 100644 --- a/utils/src/main/java/com/cloud/utils/crypt/DBEncryptionUtil.java +++ b/utils/src/main/java/com/cloud/utils/crypt/DBEncryptionUtil.java @@ -21,7 +21,8 @@ import java.util.Properties; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; import org.jasypt.exceptions.EncryptionOperationNotPossibleException; @@ -30,7 +31,7 @@ public class DBEncryptionUtil { - public static final Logger s_logger = Logger.getLogger(DBEncryptionUtil.class); + public static final Logger LOG = LogFactory.getLogger(DBEncryptionUtil.class); private static StandardPBEStringEncryptor s_encryptor = null; public static String encrypt(String plain) { @@ -44,7 +45,7 @@ public static String encrypt(String plain) { try { encryptedString = s_encryptor.encrypt(plain); } catch (EncryptionOperationNotPossibleException e) { - s_logger.debug("Error while encrypting: " + plain); + LOG.debug("Error while encrypting: " + plain); throw e; } return encryptedString; @@ -62,7 +63,7 @@ public static String decrypt(String encrypted) { try { plain = s_encryptor.decrypt(encrypted); } catch (EncryptionOperationNotPossibleException e) { - s_logger.debug("Error while decrypting: " + encrypted); + LOG.debug("Error while decrypting: " + encrypted); throw e; } return plain; diff --git a/utils/src/main/java/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java b/utils/src/main/java/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java index 65249878bded..5b2e8c3d3040 100644 --- a/utils/src/main/java/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java +++ b/utils/src/main/java/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java @@ -30,7 +30,8 @@ import javax.annotation.PostConstruct; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig; @@ -39,7 +40,7 @@ public class EncryptionSecretKeyChecker { - private static final Logger s_logger = Logger.getLogger(EncryptionSecretKeyChecker.class); + private static final Logger LOG = LogFactory.getLogger(EncryptionSecretKeyChecker.class); // Two possible locations with the new packaging naming private static final String s_altKeyFile = "key"; @@ -58,14 +59,14 @@ public void init() { public void check(Properties dbProps) throws IOException { String encryptionType = dbProps.getProperty("db.cloud.encryption.type"); - s_logger.debug("Encryption Type: " + encryptionType); + LOG.debug("Encryption Type: " + encryptionType); if (encryptionType == null || encryptionType.equals("none")) { return; } if (s_useEncryption) { - s_logger.warn("Encryption already enabled, is check() called twice?"); + LOG.warn("Encryption already enabled, is check() called twice?"); return; } @@ -102,7 +103,7 @@ public void check(Properties dbProps) throws IOException { } else if (encryptionType.equals("web")) { int port = 8097; try (ServerSocket serverSocket = new ServerSocket(port);) { - s_logger.info("Waiting for admin to send secret key on port " + port); + LOG.info("Waiting for admin to send secret key on port " + port); try ( Socket clientSocket = serverSocket.accept(); PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true); diff --git a/utils/src/main/java/com/cloud/utils/crypt/RSAHelper.java b/utils/src/main/java/com/cloud/utils/crypt/RSAHelper.java index 692ac225c904..32ff727c3d53 100644 --- a/utils/src/main/java/com/cloud/utils/crypt/RSAHelper.java +++ b/utils/src/main/java/com/cloud/utils/crypt/RSAHelper.java @@ -34,11 +34,12 @@ import javax.crypto.Cipher; import org.apache.commons.codec.binary.Base64; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.bouncycastle.jce.provider.BouncyCastleProvider; public class RSAHelper { - final static Logger s_logger = Logger.getLogger(RSAHelper.class); + final static Logger LOG = LogFactory.getLogger(RSAHelper.class); static { BouncyCastleProvider provider = new BouncyCastleProvider(); @@ -81,7 +82,7 @@ public static String encryptWithSSHPublicKey(String sshPublicKey, String content byte[] encrypted = cipher.doFinal(content.getBytes()); returnString = Base64.encodeBase64String(encrypted); } catch (Exception e) { - s_logger.info("[ignored]" + LOG.info("[ignored]" + "error during public key encryption: " + e.getLocalizedMessage()); } diff --git a/utils/src/main/java/com/cloud/utils/db/DbProperties.java b/utils/src/main/java/com/cloud/utils/db/DbProperties.java index 84206146e64c..29d7002d22b4 100644 --- a/utils/src/main/java/com/cloud/utils/db/DbProperties.java +++ b/utils/src/main/java/com/cloud/utils/db/DbProperties.java @@ -26,7 +26,8 @@ import java.util.Properties; import org.apache.commons.io.IOUtils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; import org.jasypt.properties.EncryptableProperties; @@ -35,7 +36,7 @@ public class DbProperties { - private static final Logger log = Logger.getLogger(DbProperties.class); + private static final Logger log = LogFactory.getLogger(DbProperties.class); private static Properties properties = new Properties(); private static boolean loaded = false; diff --git a/utils/src/main/java/com/cloud/utils/events/SubscriptionMgr.java b/utils/src/main/java/com/cloud/utils/events/SubscriptionMgr.java index 254c27d21295..84f15e449c4d 100644 --- a/utils/src/main/java/com/cloud/utils/events/SubscriptionMgr.java +++ b/utils/src/main/java/com/cloud/utils/events/SubscriptionMgr.java @@ -26,10 +26,11 @@ import java.util.List; import java.util.Map; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; public class SubscriptionMgr { - protected final static Logger s_logger = Logger.getLogger(SubscriptionMgr.class); + protected final static Logger LOG = LogFactory.getLogger(SubscriptionMgr.class); private static SubscriptionMgr s_instance = new SubscriptionMgr(); @@ -78,11 +79,11 @@ public void notifySubscribers(String subject, Object sender, EventArgs args) { try { info.execute(sender, args); } catch (IllegalArgumentException e) { - s_logger.warn("Exception on notifying event subscribers: ", e); + LOG.warn("Exception on notifying event subscribers: ", e); } catch (IllegalAccessException e) { - s_logger.warn("Exception on notifying event subscribers: ", e); + LOG.warn("Exception on notifying event subscribers: ", e); } catch (InvocationTargetException e) { - s_logger.warn("Exception on notifying event subscribers: ", e); + LOG.warn("Exception on notifying event subscribers: ", e); } } } diff --git a/utils/src/main/java/com/cloud/utils/exception/CSExceptionErrorCode.java b/utils/src/main/java/com/cloud/utils/exception/CSExceptionErrorCode.java index 62af14e60330..a95251c75432 100644 --- a/utils/src/main/java/com/cloud/utils/exception/CSExceptionErrorCode.java +++ b/utils/src/main/java/com/cloud/utils/exception/CSExceptionErrorCode.java @@ -21,7 +21,8 @@ import java.util.HashMap; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; /** * CSExceptionErrorCode lists the CloudStack error codes that correspond @@ -30,7 +31,7 @@ public class CSExceptionErrorCode { - public static final Logger s_logger = Logger.getLogger(CSExceptionErrorCode.class.getName()); + public static final Logger LOG = LogFactory.getLogger(CSExceptionErrorCode.class); // Declare a hashmap of CloudStack Error Codes for Exceptions. protected static final HashMap ExceptionErrorCodeMap; @@ -88,7 +89,7 @@ public static int getCSErrCode(String exceptionName) { if (ExceptionErrorCodeMap.containsKey(exceptionName)) { return ExceptionErrorCodeMap.get(exceptionName); } else { - s_logger.info("Could not find exception: " + exceptionName + " in error code list for exceptions"); + LOG.info("Could not find exception: " + exceptionName + " in error code list for exceptions"); return -1; } } diff --git a/utils/src/main/java/com/cloud/utils/net/HTTPUtils.java b/utils/src/main/java/com/cloud/utils/net/HTTPUtils.java index 95aee6e5affc..dca9705642a3 100644 --- a/utils/src/main/java/com/cloud/utils/net/HTTPUtils.java +++ b/utils/src/main/java/com/cloud/utils/net/HTTPUtils.java @@ -27,13 +27,14 @@ import org.apache.commons.httpclient.NoHttpResponseException; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.auth.AuthScope; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import java.io.IOException; public final class HTTPUtils { - private static final Logger LOGGER = Logger.getLogger(HTTPUtils.class); + private static final Logger LOGGER = LogFactory.getLogger(HTTPUtils.class); // The connection manager. private static final MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager(); diff --git a/utils/src/main/java/com/cloud/utils/net/MacAddress.java b/utils/src/main/java/com/cloud/utils/net/MacAddress.java index d7ac9e39e7fe..b1a65e0f6f97 100644 --- a/utils/src/main/java/com/cloud/utils/net/MacAddress.java +++ b/utils/src/main/java/com/cloud/utils/net/MacAddress.java @@ -29,7 +29,8 @@ import java.net.UnknownHostException; import java.util.Formatter; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; /** * This class retrieves the (first) MAC address for the machine is it is loaded on and stores it statically for retrieval. @@ -37,7 +38,7 @@ * copied fnd addpeted rom the public domain utility from John Burkard. **/ public class MacAddress { - private static final Logger s_logger = Logger.getLogger(MacAddress.class); + private static final Logger LOG = LogFactory.getLogger(MacAddress.class); private long _addr = 0; protected MacAddress() { @@ -114,9 +115,9 @@ public String toString() { } } catch (SecurityException ex) { - s_logger.info("[ignored] security exception in static initializer of MacAddress", ex); + LOG.info("[ignored] security exception in static initializer of MacAddress", ex); } catch (IOException ex) { - s_logger.info("[ignored] io exception in static initializer of MacAddress"); + LOG.info("[ignored] io exception in static initializer of MacAddress"); } finally { if (p != null) { closeAutoCloseable(in, "closing init process input stream"); diff --git a/utils/src/main/java/com/cloud/utils/net/NetUtils.java b/utils/src/main/java/com/cloud/utils/net/NetUtils.java index dce6c257a1f3..b62f8cc92f16 100644 --- a/utils/src/main/java/com/cloud/utils/net/NetUtils.java +++ b/utils/src/main/java/com/cloud/utils/net/NetUtils.java @@ -46,7 +46,8 @@ import org.apache.commons.net.util.SubnetUtils; import org.apache.commons.validator.routines.InetAddressValidator; import org.apache.commons.validator.routines.RegexValidator; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.cloud.utils.IteratorUtil; import com.cloud.utils.Pair; @@ -57,7 +58,7 @@ import com.googlecode.ipv6.IPv6Network; public class NetUtils { - protected final static Logger s_logger = Logger.getLogger(NetUtils.class); + protected final static Logger LOG = LogFactory.getLogger(NetUtils.class); private static final int MAX_CIDR = 32; private static final int RFC_3021_31_BIT_CIDR = 31; @@ -112,7 +113,7 @@ public static String getHostName() { return localAddr.getHostName(); } } catch (final UnknownHostException e) { - s_logger.warn("UnknownHostException when trying to get host name. ", e); + LOG.warn("UnknownHostException when trying to get host name. ", e); } return "localhost"; } @@ -124,7 +125,7 @@ public static String getCanonicalHostName() { return localAddr.getCanonicalHostName(); } } catch (UnknownHostException e) { - s_logger.warn("UnknownHostException when trying to get canonical host name. ", e); + LOG.warn("UnknownHostException when trying to get canonical host name. ", e); } return "localhost"; } @@ -133,7 +134,7 @@ public static InetAddress getLocalInetAddress() { try { return InetAddress.getLocalHost(); } catch (final UnknownHostException e) { - s_logger.warn("UnknownHostException in getLocalInetAddress().", e); + LOG.warn("UnknownHostException in getLocalInetAddress().", e); return null; } } @@ -143,7 +144,7 @@ public static String resolveToIp(final String host) { final InetAddress addr = InetAddress.getByName(host); return addr.getHostAddress(); } catch (final UnknownHostException e) { - s_logger.warn("Unable to resolve " + host + " to IP due to UnknownHostException"); + LOG.warn("Unable to resolve " + host + " to IP due to UnknownHostException"); return null; } } @@ -159,7 +160,7 @@ public static InetAddress[] getAllLocalInetAddresses() { } } } catch (final SocketException e) { - s_logger.warn("SocketException in getAllLocalInetAddresses().", e); + LOG.warn("SocketException in getAllLocalInetAddresses().", e); } final InetAddress[] addrs = new InetAddress[addrList.size()]; @@ -189,7 +190,7 @@ public static String[] getLocalCidrs() { } } } catch (final SocketException e) { - s_logger.warn("UnknownHostException in getLocalCidrs().", e); + LOG.warn("UnknownHostException in getLocalCidrs().", e); } return cidrList.toArray(new String[0]); @@ -211,7 +212,7 @@ public static String getDefaultHostIp() { line = output.readLine(); } } catch (final IOException e) { - s_logger.debug("Caught IOException", e); + LOG.debug("Caught IOException", e); } return null; } else { @@ -232,7 +233,7 @@ public static String getDefaultHostIp() { try { info = NetUtils.getNetworkParams(nic); } catch (final NullPointerException ignored) { - s_logger.debug("Caught NullPointerException when trying to getDefaultHostIp"); + LOG.debug("Caught NullPointerException when trying to getDefaultHostIp"); } if (info != null) { return info[0]; @@ -324,7 +325,7 @@ public static String getMacAddress(final InetAddress address) { formatter.format("%02X%s", mac[i], i < mac.length - 1 ? ":" : ""); } } catch (final SocketException e) { - s_logger.error("SocketException when trying to retrieve MAC address", e); + LOG.error("SocketException when trying to retrieve MAC address", e); } finally { formatter.close(); } @@ -431,7 +432,7 @@ public static String[] getNetworkParams(final NetworkInterface nic) { final byte[] mac = nic.getHardwareAddress(); result[1] = byte2Mac(mac); } catch (final SocketException e) { - s_logger.debug("Caught exception when trying to get the mac address ", e); + LOG.debug("Caught exception when trying to get the mac address ", e); } result[2] = prefix2Netmask(addr.getNetworkPrefixLength()); @@ -1002,16 +1003,16 @@ public static boolean verifyDomainNameLabel(final String hostName, final boolean // If it's a host name, don't allow to start with digit if (hostName.length() > 63 || hostName.length() < 1) { - s_logger.warn("Domain name label must be between 1 and 63 characters long"); + LOG.warn("Domain name label must be between 1 and 63 characters long"); return false; } else if (!hostName.toLowerCase().matches("[a-z0-9-]*")) { - s_logger.warn("Domain name label may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner)"); + LOG.warn("Domain name label may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner)"); return false; } else if (hostName.startsWith("-") || hostName.endsWith("-")) { - s_logger.warn("Domain name label can not start with a hyphen and digit, and must not end with a hyphen"); + LOG.warn("Domain name label can not start with a hyphen and digit, and must not end with a hyphen"); return false; } else if (isHostName && hostName.matches("^[0-9-].*")) { - s_logger.warn("Host name can't start with digit"); + LOG.warn("Host name can't start with digit"); return false; } @@ -1021,12 +1022,12 @@ public static boolean verifyDomainNameLabel(final String hostName, final boolean public static boolean verifyDomainName(final String domainName) { // don't allow domain name length to exceed 190 chars (190 + 63 (max host name length) = 253 = max domainName length if (domainName.length() < 1 || domainName.length() > 190) { - s_logger.trace("Domain name must be between 1 and 190 characters long"); + LOG.trace("Domain name must be between 1 and 190 characters long"); return false; } if (domainName.startsWith(".") || domainName.endsWith(".")) { - s_logger.trace("Domain name can't start or end with ."); + LOG.trace("Domain name can't start or end with ."); return false; } @@ -1034,7 +1035,7 @@ public static boolean verifyDomainName(final String domainName) { for (int i = 0; i < domainNameLabels.length; i++) { if (!verifyDomainNameLabel(domainNameLabels[i], false)) { - s_logger.warn("Domain name label " + domainNameLabels[i] + " is incorrect"); + LOG.warn("Domain name label " + domainNameLabels[i] + " is incorrect"); return false; } } @@ -1052,11 +1053,11 @@ public static String getDhcpRange(final String cidr) { public static boolean isSameIpRange(final String cidrA, final String cidrB) { if (!NetUtils.isValidIp4Cidr(cidrA)) { - s_logger.info("Invalid value of cidr " + cidrA); + LOG.info("Invalid value of cidr " + cidrA); return false; } if (!NetUtils.isValidIp4Cidr(cidrB)) { - s_logger.info("Invalid value of cidr " + cidrB); + LOG.info("Invalid value of cidr " + cidrB); return false; } final String[] cidrPairFirst = cidrA.split("\\/"); @@ -1090,7 +1091,7 @@ public static boolean validateGuestCidr(final String cidr) { final String[] allowedNetBlocks = {"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "100.64.0.0/10"}; if (!isValidIp4Cidr(cidr)) { - s_logger.warn("Cidr " + cidr + " is not valid"); + LOG.warn("Cidr " + cidr + " is not valid"); return false; } @@ -1101,7 +1102,7 @@ public static boolean validateGuestCidr(final String cidr) { } // not in allowedNetBlocks - return false - s_logger.warn("cidr " + cidr + " is not RFC 1918 or 6598 compliant"); + LOG.warn("cidr " + cidr + " is not RFC 1918 or 6598 compliant"); return false; } @@ -1125,7 +1126,7 @@ public static boolean isUnicastMac(final String macAddr) { public static boolean verifyInstanceName(final String instanceName) { //instance name for cloudstack vms shouldn't contain - and spaces if (instanceName.contains("-") || instanceName.contains(" ") || instanceName.contains("+")) { - s_logger.warn("Instance name can not contain hyphen, spaces and \"+\" char"); + LOG.warn("Instance name can not contain hyphen, spaces and \"+\" char"); return false; } return true; @@ -1138,7 +1139,7 @@ public static boolean isNetworksOverlap(final String cidrA, final String cidrB) final long shift = MAX_CIDR - (cidrALong[1] > cidrBLong[1] ? cidrBLong[1] : cidrALong[1]); return cidrALong[0] >> shift == cidrBLong[0] >> shift; } catch (CloudRuntimeException e) { - s_logger.error(e.getLocalizedMessage(),e); + LOG.error(e.getLocalizedMessage(),e); } return false; } @@ -1205,7 +1206,7 @@ public static boolean validateGuestCidrList(final String guestCidrList) { public static boolean validateIcmpType(final long icmpType) { //Source - http://www.erg.abdn.ac.uk/~gorry/course/inet-pages/icmp-code.html if (!(icmpType >= 0 && icmpType <= 255)) { - s_logger.warn("impcType is not within 0-255 range"); + LOG.warn("impcType is not within 0-255 range"); return false; } return true; @@ -1215,7 +1216,7 @@ public static boolean validateIcmpCode(final long icmpCode) { //Source - http://www.erg.abdn.ac.uk/~gorry/course/inet-pages/icmp-code.html if (!(icmpCode >= 0 && icmpCode <= 15)) { - s_logger.warn("Icmp code should be within 0-15 range"); + LOG.warn("Icmp code should be within 0-15 range"); return false; } @@ -1310,7 +1311,7 @@ public static BigInteger countIp6InRange(final String ip6Range) { return endInt.subtract(startInt).add(BigInteger.ONE); } } catch (final IllegalArgumentException ex) { - s_logger.error("Failed to convert a string to an IPv6 address", ex); + LOG.error("Failed to convert a string to an IPv6 address", ex); } return null; } diff --git a/utils/src/main/java/com/cloud/utils/nicira/nvp/plugin/NiciraNvpApiVersion.java b/utils/src/main/java/com/cloud/utils/nicira/nvp/plugin/NiciraNvpApiVersion.java index 9090de755a3e..559fafeda18c 100755 --- a/utils/src/main/java/com/cloud/utils/nicira/nvp/plugin/NiciraNvpApiVersion.java +++ b/utils/src/main/java/com/cloud/utils/nicira/nvp/plugin/NiciraNvpApiVersion.java @@ -19,12 +19,13 @@ package com.cloud.utils.nicira.nvp.plugin; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.apache.cloudstack.utils.CloudStackVersion; public class NiciraNvpApiVersion { - private static final Logger s_logger = Logger.getLogger(NiciraNvpApiVersion.class); + private static final Logger LOG = LogFactory.getLogger(NiciraNvpApiVersion.class); private static String niciraApiVersion; @@ -41,7 +42,7 @@ public static synchronized boolean isApiVersionLowerThan(String apiVersion){ } public static synchronized void logNiciraApiVersion(){ - s_logger.info("NSX API VERSION: " + ((niciraApiVersion != null) ? niciraApiVersion : " NOT PRESENT")); + LOG.info("NSX API VERSION: " + ((niciraApiVersion != null) ? niciraApiVersion : " NOT PRESENT")); } } diff --git a/utils/src/main/java/com/cloud/utils/nio/Link.java b/utils/src/main/java/com/cloud/utils/nio/Link.java index 658244087709..314a20a1f1f5 100644 --- a/utils/src/main/java/com/cloud/utils/nio/Link.java +++ b/utils/src/main/java/com/cloud/utils/nio/Link.java @@ -48,7 +48,8 @@ import org.apache.cloudstack.framework.ca.CAService; import org.apache.cloudstack.utils.security.KeyStoreUtils; import org.apache.cloudstack.utils.security.SSLUtils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.cloud.utils.PropertiesUtil; import com.cloud.utils.exception.CloudRuntimeException; @@ -56,7 +57,7 @@ /** */ public class Link { - private static final Logger s_logger = Logger.getLogger(Link.class); + private static final Logger LOG = LogFactory.getLogger(Link.class); private final InetSocketAddress _addr; private final NioConnection _connection; @@ -141,15 +142,15 @@ private static void doWrite(SocketChannel ch, ByteBuffer[] buffers, SSLEngine ss headBuf.flip(); while (headRemaining > 0) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Writing Header " + headRemaining); + if (LOG.isTraceEnabled()) { + LOG.trace("Writing Header " + headRemaining); } long count = ch.write(headBuf); headRemaining -= count; } while (dataRemaining > 0) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Writing Data " + dataRemaining); + if (LOG.isTraceEnabled()) { + LOG.trace("Writing Data " + dataRemaining); } long count = ch.write(pkgBuf); dataRemaining -= count; @@ -187,14 +188,14 @@ public byte[] read(SocketChannel ch) throws IOException { } if (_readBuffer.hasRemaining()) { - s_logger.trace("Need to read the rest of the packet length"); + LOG.trace("Need to read the rest of the packet length"); return null; } _readBuffer.flip(); int header = _readBuffer.getInt(); int readSize = (short)header; - if (s_logger.isTraceEnabled()) { - s_logger.trace("Packet length is " + readSize); + if (LOG.isTraceEnabled()) { + LOG.trace("Packet length is " + readSize); } if (readSize > MAX_SIZE_PER_PACKET) { @@ -215,8 +216,8 @@ public byte[] read(SocketChannel ch) throws IOException { _readHeader = false; if (_readBuffer.capacity() < readSize) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Resizing the byte buffer from " + _readBuffer.capacity()); + if (LOG.isTraceEnabled()) { + LOG.trace("Resizing the byte buffer from " + _readBuffer.capacity()); } _readBuffer = ByteBuffer.allocate(readSize); } @@ -228,8 +229,8 @@ public byte[] read(SocketChannel ch) throws IOException { } if (_readBuffer.hasRemaining()) { // We're not done yet. - if (s_logger.isTraceEnabled()) { - s_logger.trace("Still has " + _readBuffer.remaining()); + if (LOG.isTraceEnabled()) { + LOG.trace("Still has " + _readBuffer.remaining()); } return null; } @@ -263,8 +264,8 @@ public byte[] read(SocketChannel ch) throws IOException { _plaintextBuffer = newBuffer; } _plaintextBuffer.put(appBuf); - if (s_logger.isTraceEnabled()) { - s_logger.trace("Done with packet: " + appBuf.limit()); + if (LOG.isTraceEnabled()) { + LOG.trace("Done with packet: " + appBuf.limit()); } } @@ -277,8 +278,8 @@ public byte[] read(SocketChannel ch) throws IOException { _plaintextBuffer.get(result); return result; } else { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Waiting for more packets"); + if (LOG.isTraceEnabled()) { + LOG.trace("Waiting for more packets"); } return null; } @@ -304,8 +305,8 @@ public void send(ByteBuffer[] data, boolean close) throws ClosedChannelException item[0].putInt(remaining); item[0].flip(); - if (s_logger.isTraceEnabled()) { - s_logger.trace("Sending packet of length " + remaining); + if (LOG.isTraceEnabled()) { + LOG.trace("Sending packet of length " + remaining); } _writeQueue.add(item); @@ -334,8 +335,8 @@ public boolean write(SocketChannel ch) throws IOException { ByteBuffer[] data = null; while ((data = _writeQueue.poll()) != null) { if (data.length == 0) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Closing connection requested"); + if (LOG.isTraceEnabled()) { + LOG.trace("Closing connection requested"); } return true; } @@ -378,7 +379,7 @@ public static SSLEngine initServerSSLEngine(final CAService caService, final Str if (caService != null) { return caService.createSSLEngine(sslContext, clientAddress); } - s_logger.error("CA service is not configured, by-passing CA manager to create SSL engine"); + LOG.error("CA service is not configured, by-passing CA manager to create SSL engine"); char[] passphrase = KeyStoreUtils.DEFAULT_KS_PASSPHRASE; final KeyStore ks = loadKeyStore(NioConnection.class.getResourceAsStream("/cloud.keystore"), passphrase); final KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); @@ -412,7 +413,7 @@ public static SSLContext initClientSSLContext() throws GeneralSecurityException, char[] passphrase = KeyStoreUtils.DEFAULT_KS_PASSPHRASE; File confFile = PropertiesUtil.findConfigFile("agent.properties"); if (confFile != null) { - s_logger.info("Conf file found: " + confFile.getAbsolutePath()); + LOG.info("Conf file found: " + confFile.getAbsolutePath()); final String pass = PropertiesUtil.loadFromFile(confFile).getProperty(KeyStoreUtils.KS_PASSPHRASE_PROPERTY); if (pass != null) { passphrase = pass.toCharArray(); @@ -437,7 +438,7 @@ public static SSLContext initClientSSLContext() throws GeneralSecurityException, } else { // This enforces a one-way SSL authentication tms = new TrustManager[]{new TrustAllManager()}; - s_logger.warn("Failed to load keystore, using trust all manager"); + LOG.warn("Failed to load keystore, using trust all manager"); } if (stream != null) { @@ -489,7 +490,7 @@ private static HandshakeHolder doHandshakeUnwrap(final SocketChannel socketChann try { sslEngine.closeInbound(); } catch (SSLException e) { - s_logger.warn("This SSL engine was forced to close inbound due to end of stream."); + LOG.warn("This SSL engine was forced to close inbound due to end of stream."); } sslEngine.closeOutbound(); // After closeOutbound the engine will be set to WRAP state, @@ -502,7 +503,7 @@ private static HandshakeHolder doHandshakeUnwrap(final SocketChannel socketChann result = sslEngine.unwrap(peerNetData, peerAppData); peerNetData.compact(); } catch (final SSLException sslException) { - s_logger.error(String.format("SSL error caught during unwrap data: %s, for local address=%s, remote address=%s. The client may have invalid ca-certificates.", + LOG.error(String.format("SSL error caught during unwrap data: %s, for local address=%s, remote address=%s. The client may have invalid ca-certificates.", sslException.getMessage(), socketChannel.getLocalAddress(), socketChannel.getRemoteAddress())); sslEngine.closeOutbound(); return new HandshakeHolder(peerAppData, peerNetData, false); @@ -547,7 +548,7 @@ private static HandshakeHolder doHandshakeWrap(final SocketChannel socketChannel try { result = sslEngine.wrap(myAppData, myNetData); } catch (final SSLException sslException) { - s_logger.error(String.format("SSL error caught during wrap data: %s, for local address=%s, remote address=%s.", + LOG.error(String.format("SSL error caught during wrap data: %s, for local address=%s, remote address=%s.", sslException.getMessage(), socketChannel.getLocalAddress(), socketChannel.getRemoteAddress())); sslEngine.closeOutbound(); return new HandshakeHolder(myAppData, myNetData, true); @@ -581,7 +582,7 @@ private static HandshakeHolder doHandshakeWrap(final SocketChannel socketChannel // so we make sure that peerNetData is clear to read. peerNetData.clear(); } catch (Exception e) { - s_logger.error("Failed to send server's CLOSE message due to socket channel's failure."); + LOG.error("Failed to send server's CLOSE message due to socket channel's failure."); } break; default: @@ -609,7 +610,7 @@ public static boolean doHandshake(final SocketChannel socketChannel, final SSLEn && handshakeStatus != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { final long timeTaken = System.currentTimeMillis() - startTimeMills; if (timeTaken > 15000L) { - s_logger.warn("SSL Handshake has taken more than 15s to connect to: " + socketChannel.getRemoteAddress() + + LOG.warn("SSL Handshake has taken more than 15s to connect to: " + socketChannel.getRemoteAddress() + ". Please investigate this connection."); return false; } @@ -632,8 +633,8 @@ public static boolean doHandshake(final SocketChannel socketChannel, final SSLEn case NEED_TASK: Runnable task; while ((task = sslEngine.getDelegatedTask()) != null) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("SSL: Running delegated task!"); + if (LOG.isTraceEnabled()) { + LOG.trace("SSL: Running delegated task!"); } executor.execute(task); } diff --git a/utils/src/main/java/com/cloud/utils/nio/NioClient.java b/utils/src/main/java/com/cloud/utils/nio/NioClient.java index d4a1e02e1f86..0b521d24de67 100644 --- a/utils/src/main/java/com/cloud/utils/nio/NioClient.java +++ b/utils/src/main/java/com/cloud/utils/nio/NioClient.java @@ -30,10 +30,11 @@ import javax.net.ssl.SSLEngine; import org.apache.cloudstack.utils.security.SSLUtils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; public class NioClient extends NioConnection { - private static final Logger s_logger = Logger.getLogger(NioClient.class); + private static final Logger LOG = LogFactory.getLogger(NioClient.class); protected String _host; protected SocketChannel _clientConnection; @@ -51,7 +52,7 @@ protected void init() throws IOException { try { _clientConnection = SocketChannel.open(); - s_logger.info("Connecting to " + _host + ":" + _port); + LOG.info("Connecting to " + _host + ":" + _port); final InetSocketAddress peerAddr = new InetSocketAddress(_host, _port); _clientConnection.connect(peerAddr); _clientConnection.configureBlocking(false); @@ -62,12 +63,12 @@ protected void init() throws IOException { sslEngine.setEnabledProtocols(SSLUtils.getSupportedProtocols(sslEngine.getEnabledProtocols())); sslEngine.beginHandshake(); if (!Link.doHandshake(_clientConnection, sslEngine)) { - s_logger.error("SSL Handshake failed while connecting to host: " + _host + " port: " + _port); + LOG.error("SSL Handshake failed while connecting to host: " + _host + " port: " + _port); _selector.close(); throw new IOException("SSL Handshake failed while connecting to host: " + _host + " port: " + _port); } - s_logger.info("SSL: Handshake done"); - s_logger.info("Connected to " + _host + ":" + _port); + LOG.info("SSL: Handshake done"); + LOG.info("Connected to " + _host + ":" + _port); final Link link = new Link(peerAddr, this); link.setSSLEngine(sslEngine); @@ -103,6 +104,6 @@ public void cleanUp() throws IOException { if (_clientConnection != null) { _clientConnection.close(); } - s_logger.info("NioClient connection closed"); + LOG.info("NioClient connection closed"); } -} \ No newline at end of file +} diff --git a/utils/src/main/java/com/cloud/utils/nio/NioConnection.java b/utils/src/main/java/com/cloud/utils/nio/NioConnection.java index 9a5bf7e41539..3120b6a271ca 100644 --- a/utils/src/main/java/com/cloud/utils/nio/NioConnection.java +++ b/utils/src/main/java/com/cloud/utils/nio/NioConnection.java @@ -48,7 +48,8 @@ import org.apache.cloudstack.framework.ca.CAService; import org.apache.cloudstack.utils.security.SSLUtils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.cloud.utils.concurrency.NamedThreadFactory; import com.cloud.utils.exception.NioConnectionException; @@ -58,7 +59,7 @@ * provides that. */ public abstract class NioConnection implements Callable { - private static final Logger s_logger = Logger.getLogger(NioConnection.class);; + private static final Logger LOG = LogFactory.getLogger(NioConnection.class);; protected Selector _selector; protected ExecutorService _threadExecutor; @@ -94,13 +95,13 @@ public void start() throws NioConnectionException { try { init(); } catch (final ConnectException e) { - s_logger.warn("Unable to connect to remote: is there a server running on port " + _port); + LOG.warn("Unable to connect to remote: is there a server running on port " + _port); return; } catch (final IOException e) { - s_logger.error("Unable to initialize the threads.", e); + LOG.error("Unable to initialize the threads.", e); throw new NioConnectionException(e.getMessage(), e); } catch (final Exception e) { - s_logger.error("Unable to initialize the threads due to unknown exception.", e); + LOG.error("Unable to initialize the threads due to unknown exception.", e); throw new NioConnectionException(e.getMessage(), e); } _isStartup = true; @@ -137,8 +138,8 @@ public Boolean call() throws NioConnectionException { final Set readyKeys = _selector.selectedKeys(); final Iterator i = readyKeys.iterator(); - if (s_logger.isTraceEnabled()) { - s_logger.trace("Keys Processing: " + readyKeys.size()); + if (LOG.isTraceEnabled()) { + LOG.trace("Keys Processing: " + readyKeys.size()); } // Walk through the ready keys collection. while (i.hasNext()) { @@ -146,8 +147,8 @@ public Boolean call() throws NioConnectionException { i.remove(); if (!sk.isValid()) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Selection Key is invalid: " + sk.toString()); + if (LOG.isTraceEnabled()) { + LOG.trace("Selection Key is invalid: " + sk.toString()); } final Link link = (Link)sk.attachment(); if (link != null) { @@ -166,7 +167,7 @@ public Boolean call() throws NioConnectionException { } } - s_logger.trace("Keys Done Processing."); + LOG.trace("Keys Done Processing."); processTodos(); } catch (final ClosedSelectorException e) { @@ -175,7 +176,7 @@ public Boolean call() throws NioConnectionException { * We do not log it here otherwise we will fill the disk with messages. */ } catch (final IOException e) { - s_logger.error("Agent will die due to this IOException!", e); + LOG.error("Agent will die due to this IOException!", e); throw new NioConnectionException(e.getMessage(), e); } } @@ -197,8 +198,8 @@ protected void accept(final SelectionKey key) throws IOException { final Socket socket = socketChannel.socket(); socket.setKeepAlive(true); - if (s_logger.isTraceEnabled()) { - s_logger.trace("Connection accepted for " + socket); + if (LOG.isTraceEnabled()) { + LOG.trace("Connection accepted for " + socket); } final SSLEngine sslEngine; @@ -216,8 +217,8 @@ public void run() { if (!Link.doHandshake(socketChannel, sslEngine)) { throw new IOException("SSL handshake timed out with " + socketChannel.getRemoteAddress()); } - if (s_logger.isTraceEnabled()) { - s_logger.trace("SSL: Handshake done"); + if (LOG.isTraceEnabled()) { + LOG.trace("SSL: Handshake done"); } final InetSocketAddress saddr = (InetSocketAddress)socket.getRemoteSocketAddress(); final Link link = new Link(saddr, nioConnection); @@ -227,8 +228,8 @@ public void run() { registerLink(saddr, link); _executor.submit(task); } catch (IOException e) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Connection closed due to failure: " + e.getMessage()); + if (LOG.isTraceEnabled()) { + LOG.trace("Connection closed due to failure: " + e.getMessage()); } closeAutoCloseable(socket, "accepting socket"); closeAutoCloseable(socketChannel, "accepting socketChannel"); @@ -238,8 +239,8 @@ public void run() { } }); } catch (final Exception e) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Connection closed due to failure: " + e.getMessage()); + if (LOG.isTraceEnabled()) { + LOG.trace("Connection closed due to failure: " + e.getMessage()); } closeAutoCloseable(socket, "accepting socket"); closeAutoCloseable(socketChannel, "accepting socketChannel"); @@ -259,7 +260,7 @@ protected void terminate(final SelectionKey key) { try { _executor.submit(task); } catch (final Exception e) { - s_logger.warn("Exception occurred when submitting the task", e); + LOG.warn("Exception occurred when submitting the task", e); } } } @@ -268,13 +269,13 @@ protected void read(final SelectionKey key) throws IOException { final Link link = (Link)key.attachment(); try { final SocketChannel socketChannel = (SocketChannel)key.channel(); - if (s_logger.isTraceEnabled()) { - s_logger.trace("Reading from: " + socketChannel.socket().toString()); + if (LOG.isTraceEnabled()) { + LOG.trace("Reading from: " + socketChannel.socket().toString()); } final byte[] data = link.read(socketChannel); if (data == null) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Packet is incomplete. Waiting for more."); + if (LOG.isTraceEnabled()) { + LOG.trace("Packet is incomplete. Waiting for more."); } return; } @@ -283,7 +284,7 @@ protected void read(final SelectionKey key) throws IOException { try { _executor.submit(task); } catch (final Exception e) { - s_logger.warn("Exception occurred when submitting the task", e); + LOG.warn("Exception occurred when submitting the task", e); } } catch (final Exception e) { logDebug(e, key, 1); @@ -292,7 +293,7 @@ protected void read(final SelectionKey key) throws IOException { } protected void logTrace(final Exception e, final SelectionKey key, final int loc) { - if (s_logger.isTraceEnabled()) { + if (LOG.isTraceEnabled()) { Socket socket = null; if (key != null) { final SocketChannel ch = (SocketChannel)key.channel(); @@ -301,12 +302,12 @@ protected void logTrace(final Exception e, final SelectionKey key, final int loc } } - s_logger.trace("Location " + loc + ": Socket " + socket + " closed on read. Probably -1 returned."); + LOG.trace("Location " + loc + ": Socket " + socket + " closed on read. Probably -1 returned."); } } protected void logDebug(final Exception e, final SelectionKey key, final int loc) { - if (s_logger.isDebugEnabled()) { + if (LOG.isDebugEnabled()) { Socket socket = null; if (key != null) { final SocketChannel ch = (SocketChannel)key.channel(); @@ -315,7 +316,7 @@ protected void logDebug(final Exception e, final SelectionKey key, final int loc } } - s_logger.debug("Location " + loc + ": Socket " + socket + " closed on read. Probably -1 returned: " + e.getMessage()); + LOG.debug("Location " + loc + ": Socket " + socket + " closed on read. Probably -1 returned: " + e.getMessage()); } } @@ -330,8 +331,8 @@ protected void processTodos() { _todos = new ArrayList(); } - if (s_logger.isTraceEnabled()) { - s_logger.trace("Todos Processing: " + todos.size()); + if (LOG.isTraceEnabled()) { + LOG.trace("Todos Processing: " + todos.size()); } SelectionKey key; for (final ChangeRequest todo : todos) { @@ -348,7 +349,7 @@ protected void processTodos() { key.interestOps(todo.ops); } } catch (final CancelledKeyException e) { - s_logger.debug("key has been cancelled"); + LOG.debug("key has been cancelled"); } break; case ChangeRequest.REGISTER: @@ -359,11 +360,11 @@ protected void processTodos() { link.setKey(key); } } catch (final ClosedChannelException e) { - s_logger.warn("Couldn't register socket: " + todo.key); + LOG.warn("Couldn't register socket: " + todo.key); try { ((SocketChannel)todo.key).close(); } catch (final IOException ignore) { - s_logger.info("[ignored] socket channel"); + LOG.info("[ignored] socket channel"); } finally { final Link link = (Link)todo.att; link.terminated(); @@ -371,8 +372,8 @@ protected void processTodos() { } break; case ChangeRequest.CLOSE: - if (s_logger.isTraceEnabled()) { - s_logger.trace("Trying to close " + todo.key); + if (LOG.isTraceEnabled()) { + LOG.trace("Trying to close " + todo.key); } key = (SelectionKey)todo.key; closeConnection(key); @@ -384,11 +385,11 @@ protected void processTodos() { } break; default: - s_logger.warn("Shouldn't be here"); + LOG.warn("Shouldn't be here"); throw new RuntimeException("Shouldn't be here"); } } - s_logger.trace("Todos Done processing"); + LOG.trace("Todos Done processing"); } protected void connect(final SelectionKey key) throws IOException { @@ -401,8 +402,8 @@ protected void connect(final SelectionKey key) throws IOException { if (!socket.getKeepAlive()) { socket.setKeepAlive(true); } - if (s_logger.isDebugEnabled()) { - s_logger.debug("Connected to " + socket); + if (LOG.isDebugEnabled()) { + LOG.debug("Connected to " + socket); } final Link link = new Link((InetSocketAddress)socket.getRemoteSocketAddress(), this); link.setKey(key); @@ -412,7 +413,7 @@ protected void connect(final SelectionKey key) throws IOException { try { _executor.submit(task); } catch (final Exception e) { - s_logger.warn("Exception occurred when submitting the task", e); + LOG.warn("Exception occurred when submitting the task", e); } } catch (final IOException e) { logTrace(e, key, 2); @@ -424,15 +425,15 @@ protected void scheduleTask(final Task task) { try { _executor.submit(task); } catch (final Exception e) { - s_logger.warn("Exception occurred when submitting the task", e); + LOG.warn("Exception occurred when submitting the task", e); } } protected void write(final SelectionKey key) throws IOException { final Link link = (Link)key.attachment(); try { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Writing to " + link.getSocketAddress().toString()); + if (LOG.isTraceEnabled()) { + LOG.trace("Writing to " + link.getSocketAddress().toString()); } final boolean close = link.write((SocketChannel)key.channel()); if (close) { @@ -453,13 +454,13 @@ protected void closeConnection(final SelectionKey key) { key.cancel(); try { if (channel != null) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Closing socket " + channel.socket()); + if (LOG.isDebugEnabled()) { + LOG.debug("Closing socket " + channel.socket()); } channel.close(); } } catch (final IOException ignore) { - s_logger.info("[ignored] channel"); + LOG.info("[ignored] channel"); } } } diff --git a/utils/src/main/java/com/cloud/utils/nio/NioServer.java b/utils/src/main/java/com/cloud/utils/nio/NioServer.java index ff54165841e9..a93882918ada 100644 --- a/utils/src/main/java/com/cloud/utils/nio/NioServer.java +++ b/utils/src/main/java/com/cloud/utils/nio/NioServer.java @@ -28,10 +28,11 @@ import java.util.WeakHashMap; import org.apache.cloudstack.framework.ca.CAService; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; public class NioServer extends NioConnection { - private final static Logger s_logger = Logger.getLogger(NioServer.class); + private final static Logger LOG = LogFactory.getLogger(NioServer.class); protected InetSocketAddress _localAddr; private ServerSocketChannel _serverSocket; @@ -61,7 +62,7 @@ protected void init() throws IOException { _serverSocket.register(_selector, SelectionKey.OP_ACCEPT, null); - s_logger.info("NioConnection started and listening on " + _serverSocket.socket().getLocalSocketAddress()); + LOG.info("NioConnection started and listening on " + _serverSocket.socket().getLocalSocketAddress()); } @Override @@ -70,7 +71,7 @@ public void cleanUp() throws IOException { if (_serverSocket != null) { _serverSocket.close(); } - s_logger.info("NioConnection stopped on " + _localAddr.toString()); + LOG.info("NioConnection stopped on " + _localAddr.toString()); } @Override diff --git a/utils/src/main/java/com/cloud/utils/nio/Task.java b/utils/src/main/java/com/cloud/utils/nio/Task.java index 60228ef9412e..e58df9627e37 100644 --- a/utils/src/main/java/com/cloud/utils/nio/Task.java +++ b/utils/src/main/java/com/cloud/utils/nio/Task.java @@ -83,4 +83,4 @@ public Boolean call() throws TaskExecutionException { doTask(this); return true; } -} \ No newline at end of file +} diff --git a/utils/src/main/java/com/cloud/utils/rest/BasicRestClient.java b/utils/src/main/java/com/cloud/utils/rest/BasicRestClient.java index 5c291557519d..2720fed9d198 100644 --- a/utils/src/main/java/com/cloud/utils/rest/BasicRestClient.java +++ b/utils/src/main/java/com/cloud/utils/rest/BasicRestClient.java @@ -27,11 +27,12 @@ import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; public class BasicRestClient implements RestClient { - private static final Logger s_logger = Logger.getLogger(BasicRestClient.class); + private static final Logger LOG = LogFactory.getLogger(BasicRestClient.class); private static final String HTTPS = HttpConstants.HTTPS; private static final int HTTPS_PORT = HttpConstants.HTTPS_PORT; @@ -74,13 +75,13 @@ private void logRequestExecution(final HttpUriRequest request) { final URI uri = request.getURI(); String query = uri.getQuery(); query = query != null ? "?" + query : ""; - s_logger.debug("Executig " + request.getMethod() + " request on " + clientContext.getTargetHost() + uri.getPath() + query); + LOG.debug("Executig " + request.getMethod() + " request on " + clientContext.getTargetHost() + uri.getPath() + query); } @Override public void closeResponse(final CloseableHttpResponse response) throws CloudstackRESTException { try { - s_logger.debug("Closing HTTP connection"); + LOG.debug("Closing HTTP connection"); response.close(); } catch (final IOException e) { final StringBuilder sb = new StringBuilder(); diff --git a/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java b/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java index ffa2905103bb..0e801379a9f6 100644 --- a/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java +++ b/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java @@ -28,7 +28,8 @@ import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.util.EntityUtils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.google.common.base.Optional; import com.google.gson.FieldNamingPolicy; @@ -44,7 +45,7 @@ */ public class RESTServiceConnector { - private static final Logger s_logger = Logger.getLogger(RESTServiceConnector.class); + private static final Logger LOG = LogFactory.getLogger(RESTServiceConnector.class); private static final Optional ABSENT = Optional.absent(); @@ -69,7 +70,7 @@ public static Builder create() { } public void executeUpdateObject(final T newObject, final String path, final Map parameters) throws CloudstackRESTException { - s_logger.debug("Executing update object on " + path); + LOG.debug("Executing update object on " + path); client.closeResponse(createAndExecuteRequest(HttpMethods.PUT, path, parameters, Optional.fromNullable(gson.toJson(newObject)))); } @@ -79,7 +80,7 @@ public void executeUpdateObject(final T newObject, final String path) throws @SuppressWarnings("unchecked") public T executeCreateObject(final T newObject, final String path, final Map parameters) throws CloudstackRESTException { - s_logger.debug("Executing create object on " + path); + LOG.debug("Executing create object on " + path); final CloseableHttpResponse response = createAndExecuteRequest(HttpMethods.POST, path, parameters, Optional.fromNullable(gson.toJson(newObject))); return (T) readResponseBody(response, newObject.getClass()); } @@ -89,12 +90,12 @@ public T executeCreateObject(final T newObject, final String uri) throws Clo } public void executeDeleteObject(final String path) throws CloudstackRESTException { - s_logger.debug("Executing delete object on " + path); + LOG.debug("Executing delete object on " + path); client.closeResponse(createAndExecuteRequest(HttpMethods.DELETE, path, new HashMap(), ABSENT)); } public T executeRetrieveObject(final Type returnObjectType, final String path, final Map parameters) throws CloudstackRESTException { - s_logger.debug("Executing retrieve object on " + path); + LOG.debug("Executing retrieve object on " + path); final CloseableHttpResponse response = createAndExecuteRequest(HttpMethods.GET, path, parameters, ABSENT); return readResponseBody(response, returnObjectType); } @@ -112,14 +113,14 @@ private CloseableHttpResponse createAndExecuteRequest(final HttpMethods method, .method(method) .build(); if (jsonPayLoad.isPresent()) { - s_logger.debug("Built request '" + httpRequest + "' with payload: " + jsonPayLoad); + LOG.debug("Built request '" + httpRequest + "' with payload: " + jsonPayLoad); } return executeRequest(httpRequest); } private CloseableHttpResponse executeRequest(final HttpUriRequest httpRequest) throws CloudstackRESTException { final CloseableHttpResponse response = client.execute(httpRequest); - s_logger.debug("Executed request: " + httpRequest + " status was " + response.getStatusLine().toString()); + LOG.debug("Executed request: " + httpRequest + " status was " + response.getStatusLine().toString()); return response; } @@ -127,7 +128,7 @@ private T readResponseBody(final CloseableHttpResponse response, final Type final HttpEntity entity = response.getEntity(); try { final String stringEntity = EntityUtils.toString(entity); - //s_logger.debug("Response entity: " + stringEntity); + //LOG.debug("Response entity: " + stringEntity); EntityUtils.consumeQuietly(entity); return gson.fromJson(stringEntity, type); } catch (final IOException e) { diff --git a/utils/src/main/java/com/cloud/utils/script/OutputInterpreter.java b/utils/src/main/java/com/cloud/utils/script/OutputInterpreter.java index 654f87ec5bc0..6b389f147f0d 100644 --- a/utils/src/main/java/com/cloud/utils/script/OutputInterpreter.java +++ b/utils/src/main/java/com/cloud/utils/script/OutputInterpreter.java @@ -22,7 +22,8 @@ import java.io.BufferedReader; import java.io.IOException; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; /** */ @@ -50,7 +51,7 @@ public String interpret(BufferedReader reader) throws IOException { }; public static class TimedOutLogger extends OutputInterpreter { - private static final Logger s_logger = Logger.getLogger(TimedOutLogger.class); + private static final Logger LOG = LogFactory.getLogger(TimedOutLogger.class); Process _process; public TimedOutLogger(Process process) { @@ -77,7 +78,7 @@ public String interpret(BufferedReader reader) throws IOException { buff.append(reader.readLine()); } } catch (IOException e) { - s_logger.info("[ignored] can not append line to buffer",e); + LOG.info("[ignored] can not append line to buffer",e); } return buff.toString(); diff --git a/utils/src/main/java/com/cloud/utils/script/Script.java b/utils/src/main/java/com/cloud/utils/script/Script.java index 35aa24b1a84d..8f7bd66cac95 100644 --- a/utils/src/main/java/com/cloud/utils/script/Script.java +++ b/utils/src/main/java/com/cloud/utils/script/Script.java @@ -39,7 +39,8 @@ import org.apache.cloudstack.utils.security.KeyStoreUtils; import org.apache.commons.io.IOUtils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.joda.time.Duration; import com.cloud.utils.PropertiesUtil; @@ -47,7 +48,7 @@ import com.cloud.utils.script.OutputInterpreter.TimedOutLogger; public class Script implements Callable { - private static final Logger s_logger = Logger.getLogger(Script.class); + private static final Logger LOG = LogFactory.getLogger(Script.class); private final Logger _logger; @@ -70,6 +71,31 @@ public int getExitValue() { return _process.exitValue(); } + /* + * a set of constructors that are creating wrappers around log4j1 loggers to facilitate single point upgrading later on + * these are all @deprecated and only created to not have to change code outside this package {code}org.apache.utils{code} + */ + @Deprecated + public Script(String command, Duration timeout, org.apache.log4j.Logger logger) { + this(command, timeout.getMillis(), new Logger(logger)); + } + @Deprecated + public Script(String command, long timeout, org.apache.log4j.Logger logger) { + this(command, timeout, new Logger(logger)); + } + @Deprecated + public Script(String command, org.apache.log4j.Logger logger) { + this(command, new Logger(logger)); + } + @Deprecated + public Script(boolean runWithSudo, String command, Duration timeout, org.apache.log4j.Logger logger) { + this(runWithSudo, command, timeout, new Logger(logger)); + } + @Deprecated + public Script(boolean runWithSudo, String command, long timeout, org.apache.log4j.Logger logger) { + this(runWithSudo, command, timeout, new Logger(logger)); + } + public Script(String command, Duration timeout, Logger logger) { this(command, timeout.getMillis(), logger); } @@ -84,7 +110,7 @@ public Script(String command, long timeout, Logger logger) { _timeout = _defaultTimeout; } _process = null; - _logger = logger != null ? logger : s_logger; + _logger = logger != null ? logger : LOG; } public Script(boolean runWithSudo, String command, Duration timeout, Logger logger) { @@ -104,16 +130,16 @@ public Script(String command, Logger logger) { } public Script(String command) { - this(command, 0, s_logger); + this(command, 0, LOG); } public Script(String command, Duration timeout) { - this(command, timeout.getMillis(), s_logger); + this(command, timeout.getMillis(), LOG); } @Deprecated public Script(String command, long timeout) { - this(command, timeout, s_logger); + this(command, timeout, LOG); } public void add(String... params) { @@ -364,19 +390,19 @@ public synchronized String getResult() throws InterruptedException { } public static String findScript(String path, String script) { - s_logger.debug("Looking for " + script + " in the classpath"); + LOG.debug("Looking for " + script + " in the classpath"); URL url = ClassLoader.getSystemResource(script); - s_logger.debug("System resource: " + url); + LOG.debug("System resource: " + url); File file = null; if (url != null) { file = new File(url.getFile()); - s_logger.debug("Absolute path = " + file.getAbsolutePath()); + LOG.debug("Absolute path = " + file.getAbsolutePath()); return file.getAbsolutePath(); } if (path == null) { - s_logger.warn("No search path specified, unable to look for " + script); + LOG.warn("No search path specified, unable to look for " + script); return null; } path = path.replace("/", File.separator); @@ -390,14 +416,14 @@ public static String findScript(String path, String script) { } else { url = Script.class.getClassLoader().getResource(path + File.separator + script); } - s_logger.debug("Classpath resource: " + url); + LOG.debug("Classpath resource: " + url); if (url != null) { try { file = new File(new URI(url.toString()).getPath()); - s_logger.debug("Absolute path = " + file.getAbsolutePath()); + LOG.debug("Absolute path = " + file.getAbsolutePath()); return file.getAbsolutePath(); } catch (URISyntaxException e) { - s_logger.warn("Unable to convert " + url.toString() + " to a URI"); + LOG.warn("Unable to convert " + url.toString() + " to a URI"); } } @@ -411,7 +437,7 @@ public static String findScript(String path, String script) { return file.exists() ? file.getAbsolutePath() : null; } - s_logger.debug("Looking for " + script); + LOG.debug("Looking for " + script); String search = null; for (int i = 0; i < 3; i++) { if (i == 0) { @@ -431,25 +457,25 @@ public static String findScript(String path, String script) { else cp = cp.substring(begin, end); - s_logger.debug("Current binaries reside at " + cp); + LOG.debug("Current binaries reside at " + cp); search = cp; } else if (i == 1) { - s_logger.debug("Searching in environment.properties"); + LOG.debug("Searching in environment.properties"); try { final File propsFile = PropertiesUtil.findConfigFile("environment.properties"); if (propsFile == null) { - s_logger.debug("environment.properties could not be opened"); + LOG.debug("environment.properties could not be opened"); } else { final Properties props = PropertiesUtil.loadFromFile(propsFile); search = props.getProperty("paths.script"); } } catch (IOException e) { - s_logger.debug("environment.properties could not be opened"); + LOG.debug("environment.properties could not be opened"); continue; } - s_logger.debug("environment.properties says scripts should be in " + search); + LOG.debug("environment.properties says scripts should be in " + search); } else { - s_logger.debug("Searching in the current directory"); + LOG.debug("Searching in the current directory"); search = "."; } @@ -457,7 +483,7 @@ public static String findScript(String path, String script) { do { search = search.substring(0, search.lastIndexOf(File.separator)); file = new File(search + File.separator + script); - s_logger.debug("Looking for " + script + " in " + file.getAbsolutePath()); + LOG.debug("Looking for " + script + " in " + file.getAbsolutePath()); } while (!file.exists() && search.lastIndexOf(File.separator) != -1); if (file.exists()) { @@ -472,14 +498,14 @@ public static String findScript(String path, String script) { do { search = search.substring(0, search.lastIndexOf(File.separator)); file = new File(search + File.separator + script); - s_logger.debug("Looking for " + script + " in " + file.getAbsolutePath()); + LOG.debug("Looking for " + script + " in " + file.getAbsolutePath()); } while (!file.exists() && search.lastIndexOf(File.separator) != -1); if (file.exists()) { return file.getAbsolutePath(); } - s_logger.warn("Unable to find script " + script); + LOG.warn("Unable to find script " + script); return null; } diff --git a/utils/src/main/java/com/cloud/utils/script/Script2.java b/utils/src/main/java/com/cloud/utils/script/Script2.java index 03c0e0d1eb01..09b451047014 100644 --- a/utils/src/main/java/com/cloud/utils/script/Script2.java +++ b/utils/src/main/java/com/cloud/utils/script/Script2.java @@ -21,7 +21,7 @@ import java.util.HashMap; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; public class Script2 extends Script { HashMap _params = new HashMap(); @@ -30,6 +30,11 @@ public static enum ParamType { NORMAL, PASSWORD, } + @Deprecated + public Script2(String command, org.apache.log4j.Logger logger) { + this(command, new Logger(logger)); + } + public Script2(String command, Logger logger) { this(command, 0, logger); } diff --git a/utils/src/main/java/com/cloud/utils/ssh/SSHCmdHelper.java b/utils/src/main/java/com/cloud/utils/ssh/SSHCmdHelper.java index 5324cdcbc18f..8431acddc5fd 100644 --- a/utils/src/main/java/com/cloud/utils/ssh/SSHCmdHelper.java +++ b/utils/src/main/java/com/cloud/utils/ssh/SSHCmdHelper.java @@ -23,14 +23,15 @@ import java.io.InputStream; import org.apache.cloudstack.utils.security.KeyStoreUtils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.google.common.base.Strings; import com.trilead.ssh2.ChannelCondition; import com.trilead.ssh2.Session; public class SSHCmdHelper { - private static final Logger s_logger = Logger.getLogger(SSHCmdHelper.class); + private static final Logger LOG = LogFactory.getLogger(SSHCmdHelper.class); private static final int DEFAULT_CONNECT_TIMEOUT = 180000; private static final int DEFAULT_KEX_TIMEOUT = 60000; @@ -86,12 +87,12 @@ public static com.trilead.ssh2.Connection acquireAuthorizedConnection(String ip, for (int i = 0; i < methods.length; i++) { mStr.append(methods[i]); } - s_logger.warn("SSH authorizes failed, support authorized methods are " + mStr); + LOG.warn("SSH authorizes failed, support authorized methods are " + mStr); return null; } return sshConnection; } catch (IOException e) { - s_logger.warn("Get SSH connection failed", e); + LOG.warn("Get SSH connection failed", e); return null; } } @@ -139,7 +140,7 @@ public static SSHCmdResult sshExecuteCmdWithResult(com.trilead.ssh2.Connection s } public static SSHCmdResult sshExecuteCmdOneShot(com.trilead.ssh2.Connection sshConnection, String cmd) throws SshException { - s_logger.debug("Executing cmd: " + cmd.split(KeyStoreUtils.KS_FILENAME)[0]); + LOG.debug("Executing cmd: " + cmd.split(KeyStoreUtils.KS_FILENAME)[0]); Session sshSession = null; try { sshSession = sshConnection.openSession(); @@ -172,7 +173,7 @@ public static SSHCmdResult sshExecuteCmdOneShot(com.trilead.ssh2.Connection sshC if ((conditions & ChannelCondition.TIMEOUT) != 0) { String msg = "Timed out in waiting SSH execution result"; - s_logger.error(msg); + LOG.error(msg); throw new Exception(msg); } @@ -202,7 +203,7 @@ public static SSHCmdResult sshExecuteCmdOneShot(com.trilead.ssh2.Connection sshC final SSHCmdResult result = new SSHCmdResult(-1, sbStdoutResult.toString(), sbStdErrResult.toString()); if (!Strings.isNullOrEmpty(result.getStdOut()) || !Strings.isNullOrEmpty(result.getStdErr())) { - s_logger.debug("SSH command: " + cmd.split(KeyStoreUtils.KS_FILENAME)[0] + "\nSSH command output:" + result.getStdOut().split("-----BEGIN")[0] + "\n" + result.getStdErr()); + LOG.debug("SSH command: " + cmd.split(KeyStoreUtils.KS_FILENAME)[0] + "\nSSH command output:" + result.getStdOut().split("-----BEGIN")[0] + "\n" + result.getStdErr()); } // exit status delivery might get delayed @@ -216,7 +217,7 @@ public static SSHCmdResult sshExecuteCmdOneShot(com.trilead.ssh2.Connection sshC } return result; } catch (Exception e) { - s_logger.debug("Ssh executed failed", e); + LOG.debug("Ssh executed failed", e); throw new SshException("Ssh executed failed " + e.getMessage()); } finally { if (sshSession != null) diff --git a/utils/src/main/java/com/cloud/utils/ssh/SshHelper.java b/utils/src/main/java/com/cloud/utils/ssh/SshHelper.java index 88be57742257..ca09d3b87a00 100644 --- a/utils/src/main/java/com/cloud/utils/ssh/SshHelper.java +++ b/utils/src/main/java/com/cloud/utils/ssh/SshHelper.java @@ -27,7 +27,8 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.joda.time.Duration; import com.trilead.ssh2.ChannelCondition; @@ -39,7 +40,7 @@ public class SshHelper { private static final int DEFAULT_CONNECT_TIMEOUT = 180000; private static final int DEFAULT_KEX_TIMEOUT = 60000; - private static final Logger s_logger = Logger.getLogger(SshHelper.class); + private static final Logger LOG = LogFactory.getLogger(SshHelper.class); public static Pair sshExecute(String host, int port, String user, File pemKeyFile, String password, String command) throws Exception { @@ -71,13 +72,13 @@ public static void scpTo(String host, int port, String user, File pemKeyFile, St if (pemKeyFile == null) { if (!conn.authenticateWithPassword(user, password)) { String msg = "Failed to authentication SSH user " + user + " on host " + host; - s_logger.error(msg); + LOG.error(msg); throw new Exception(msg); } } else { if (!conn.authenticateWithPublicKey(user, pemKeyFile, password)) { String msg = "Failed to authentication SSH user " + user + " on host " + host; - s_logger.error(msg); + LOG.error(msg); throw new Exception(msg); } } @@ -107,13 +108,13 @@ public static void scpTo(String host, int port, String user, File pemKeyFile, St if (pemKeyFile == null) { if (!conn.authenticateWithPassword(user, password)) { String msg = "Failed to authentication SSH user " + user + " on host " + host; - s_logger.error(msg); + LOG.error(msg); throw new Exception(msg); } } else { if (!conn.authenticateWithPublicKey(user, pemKeyFile, password)) { String msg = "Failed to authentication SSH user " + user + " on host " + host; - s_logger.error(msg); + LOG.error(msg); throw new Exception(msg); } } @@ -146,13 +147,13 @@ public static Pair sshExecute(String host, int port, String use if (pemKeyFile == null) { if (!conn.authenticateWithPassword(user, password)) { String msg = "Failed to authentication SSH user " + user + " on host " + host; - s_logger.error(msg); + LOG.error(msg); throw new Exception(msg); } } else { if (!conn.authenticateWithPublicKey(user, pemKeyFile, password)) { String msg = "Failed to authentication SSH user " + user + " on host " + host; - s_logger.error(msg); + LOG.error(msg); throw new Exception(msg); } } @@ -204,19 +205,19 @@ public static Pair sshExecute(String host, int port, String use result = IOUtils.toString(stdout, StandardCharsets.UTF_8); } catch (IOException e) { - s_logger.error("Couldn't get content of input stream due to: " + e.getMessage()); + LOG.error("Couldn't get content of input stream due to: " + e.getMessage()); return new Pair(false, result); } } if (sess.getExitStatus() == null) { //Exit status is NOT available. Returning failure result. - s_logger.error(String.format("SSH execution of command %s has no exit status set. Result output: %s", command, result)); + LOG.error(String.format("SSH execution of command %s has no exit status set. Result output: %s", command, result)); return new Pair(false, result); } if (sess.getExitStatus() != null && sess.getExitStatus().intValue() != 0) { - s_logger.error(String.format("SSH execution of command %s has an error status code in return. Result output: %s", command, result)); + LOG.error(String.format("SSH execution of command %s has an error status code in return. Result output: %s", command, result)); return new Pair(false, result); } @@ -259,7 +260,7 @@ protected static boolean canEndTheSshConnection(int waitResultTimeoutInMs, com.t protected static void throwSshExceptionIfConditionsTimeout(int conditions) throws SshException { if ((conditions & ChannelCondition.TIMEOUT) != 0) { String msg = "Timed out in waiting for SSH execution exit status"; - s_logger.error(msg); + LOG.error(msg); throw new SshException(msg); } } @@ -282,7 +283,7 @@ protected static boolean isChannelConditionEof(int conditions) { protected static void throwSshExceptionIfStdoutOrStdeerIsNull(InputStream stdout, InputStream stderr) throws SshException { if (stdout == null || stderr == null) { String msg = "Stdout or Stderr of SSH session is null"; - s_logger.error(msg); + LOG.error(msg); throw new SshException(msg); } } diff --git a/utils/src/main/java/com/cloud/utils/storage/QCOW2Utils.java b/utils/src/main/java/com/cloud/utils/storage/QCOW2Utils.java index 3e08bd6634ed..6d80e0e4db57 100644 --- a/utils/src/main/java/com/cloud/utils/storage/QCOW2Utils.java +++ b/utils/src/main/java/com/cloud/utils/storage/QCOW2Utils.java @@ -57,4 +57,4 @@ public static long getVirtualSize(InputStream inputStream) throws IOException { return NumbersUtil.bytesToLong(bytes); } -} \ No newline at end of file +} diff --git a/utils/src/main/java/com/cloud/utils/storage/S3/ClientOptions.java b/utils/src/main/java/com/cloud/utils/storage/S3/ClientOptions.java index 9c9e0aaae121..13ec8575a5ab 100644 --- a/utils/src/main/java/com/cloud/utils/storage/S3/ClientOptions.java +++ b/utils/src/main/java/com/cloud/utils/storage/S3/ClientOptions.java @@ -39,4 +39,4 @@ public interface ClientOptions { Boolean getUseTCPKeepAlive(); Integer getConnectionTtl(); -} \ No newline at end of file +} diff --git a/utils/src/main/java/com/cloud/utils/storage/S3/ObjectNamingStrategy.java b/utils/src/main/java/com/cloud/utils/storage/S3/ObjectNamingStrategy.java index 04f3e87f936c..9c8fe0cba019 100644 --- a/utils/src/main/java/com/cloud/utils/storage/S3/ObjectNamingStrategy.java +++ b/utils/src/main/java/com/cloud/utils/storage/S3/ObjectNamingStrategy.java @@ -24,4 +24,4 @@ public interface ObjectNamingStrategy { String determineKey(File file); -} \ No newline at end of file +} diff --git a/utils/src/main/java/com/cloud/utils/storage/S3/S3Utils.java b/utils/src/main/java/com/cloud/utils/storage/S3/S3Utils.java index 274ff9bc9945..30a18b52b234 100644 --- a/utils/src/main/java/com/cloud/utils/storage/S3/S3Utils.java +++ b/utils/src/main/java/com/cloud/utils/storage/S3/S3Utils.java @@ -34,7 +34,8 @@ import com.amazonaws.services.s3.transfer.Download; import com.amazonaws.services.s3.transfer.TransferManager; import com.amazonaws.services.s3.transfer.Upload; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import java.io.File; import java.io.InputStream; @@ -55,7 +56,7 @@ public final class S3Utils { - private static final Logger LOGGER = Logger.getLogger(S3Utils.class); + private static final Logger LOGGER = LogFactory.getLogger(S3Utils.class); public static final String SEPARATOR = "/"; diff --git a/utils/src/main/java/com/cloud/utils/storage/encoding/Decoder.java b/utils/src/main/java/com/cloud/utils/storage/encoding/Decoder.java index c7c61d3d6048..66168a5da082 100644 --- a/utils/src/main/java/com/cloud/utils/storage/encoding/Decoder.java +++ b/utils/src/main/java/com/cloud/utils/storage/encoding/Decoder.java @@ -26,10 +26,11 @@ import java.util.List; import java.util.Map; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; public class Decoder { - private static final Logger s_logger = Logger.getLogger(Decoder.class); + private static final Logger LOG = LogFactory.getLogger(Decoder.class); private static Map getParameters(URI uri) { String parameters = uri.getQuery(); @@ -56,7 +57,7 @@ public static DecodedDataObject decode(String url) throws URISyntaxException { try { size = Long.parseLong(params.get(EncodingType.SIZE.toString())); } catch (NumberFormatException e) { - s_logger.info("[ignored] number not recognised",e); + LOG.info("[ignored] number not recognised",e); } DecodedDataObject obj = new DecodedDataObject(params.get(EncodingType.OBJTYPE.toString()), size, params.get(EncodingType.NAME.toString()), params.get(EncodingType.PATH.toString()), diff --git a/utils/src/main/java/com/cloud/utils/time/InaccurateClock.java b/utils/src/main/java/com/cloud/utils/time/InaccurateClock.java index e03231de1d46..43bb0fa12635 100644 --- a/utils/src/main/java/com/cloud/utils/time/InaccurateClock.java +++ b/utils/src/main/java/com/cloud/utils/time/InaccurateClock.java @@ -25,7 +25,8 @@ import javax.management.StandardMBean; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.cloud.utils.concurrency.NamedThreadFactory; import com.cloud.utils.mgmt.JmxUtil; @@ -34,7 +35,7 @@ */ public class InaccurateClock extends StandardMBean implements InaccurateClockMBean { - private static final Logger s_logger = Logger.getLogger(InaccurateClock.class); + private static final Logger LOG = LogFactory.getLogger(InaccurateClock.class); static ScheduledExecutorService s_executor = null; static final InaccurateClock s_timer = new InaccurateClock(); private static long time; @@ -46,7 +47,7 @@ public InaccurateClock() { try { JmxUtil.registerMBean("InaccurateClock", "InaccurateClock", this); } catch (Exception e) { - s_logger.warn("Unable to initialize inaccurate clock", e); + LOG.warn("Unable to initialize inaccurate clock", e); } } @@ -73,7 +74,7 @@ public String turnOff() { try { s_executor.shutdown(); } catch (Throwable th) { - s_logger.error("Unable to shutdown the Executor", th); + LOG.error("Unable to shutdown the Executor", th); return "Unable to turn off check logs"; } } @@ -95,7 +96,7 @@ public void run() { try { time = System.currentTimeMillis(); } catch (Throwable th) { - s_logger.error("Unable to time", th); + LOG.error("Unable to time", th); } } } 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 42af9455abb0..61e986a2672a 100644 --- a/utils/src/main/java/com/cloud/utils/xmlobject/XmlObject.java +++ b/utils/src/main/java/com/cloud/utils/xmlobject/XmlObject.java @@ -27,12 +27,13 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.logging.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.cloud.utils.exception.CloudRuntimeException; public class XmlObject { - private final Logger logger = Logger.getLogger(XmlObject.class.getName()); + private final Logger logger = LogFactory.getLogger(XmlObject.class); private final Map elements = new HashMap(); private String text; private String tag; diff --git a/utils/src/main/java/org/apache/cloudstack/utils/graphite/GraphiteException.java b/utils/src/main/java/org/apache/cloudstack/utils/graphite/GraphiteException.java index 91487645cabd..d58497f31af2 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/graphite/GraphiteException.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/graphite/GraphiteException.java @@ -28,4 +28,4 @@ public GraphiteException(String message) { public GraphiteException(String message, Throwable cause) { super(message, cause); } -} \ No newline at end of file +} diff --git a/utils/src/main/java/org/apache/cloudstack/utils/hypervisor/HypervisorUtils.java b/utils/src/main/java/org/apache/cloudstack/utils/hypervisor/HypervisorUtils.java index a0a20936bfc5..77a2581f39f4 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/hypervisor/HypervisorUtils.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/hypervisor/HypervisorUtils.java @@ -20,7 +20,8 @@ package org.apache.cloudstack.utils.hypervisor; import com.cloud.utils.exception.CloudRuntimeException; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import java.io.File; import java.io.IOException; @@ -29,7 +30,7 @@ import java.util.concurrent.TimeUnit; public class HypervisorUtils { - public static final Logger s_logger = Logger.getLogger(HypervisorUtils.class); + public static final Logger LOG = LogFactory.getLogger(HypervisorUtils.class); public static void checkVolumeFileForActivity(final String filePath, int timeoutSeconds, long inactiveThresholdMilliseconds, long minimumFileSize) throws IOException { File file = new File(filePath); @@ -37,7 +38,7 @@ public static void checkVolumeFileForActivity(final String filePath, int timeout throw new CloudRuntimeException("File " + file.getAbsolutePath() + " not found"); } if (file.length() < minimumFileSize) { - s_logger.debug("VM disk file too small, fresh clone? skipping modify check"); + LOG.debug("VM disk file too small, fresh clone? skipping modify check"); return; } int waitedSeconds = 0; @@ -47,10 +48,10 @@ public static void checkVolumeFileForActivity(final String filePath, int timeout long modifyIdle = System.currentTimeMillis() - attrs.lastModifiedTime().toMillis(); long accessIdle = System.currentTimeMillis() - attrs.lastAccessTime().toMillis(); if (modifyIdle > inactiveThresholdMilliseconds && accessIdle > inactiveThresholdMilliseconds) { - s_logger.debug("File " + filePath + " has not been accessed or modified for at least " + inactiveThresholdMilliseconds + " ms"); + LOG.debug("File " + filePath + " has not been accessed or modified for at least " + inactiveThresholdMilliseconds + " ms"); return; } else { - s_logger.debug("File was modified " + modifyIdle + "ms ago, accessed " + accessIdle + "ms ago, waiting for inactivity threshold of " + LOG.debug("File was modified " + modifyIdle + "ms ago, accessed " + accessIdle + "ms ago, waiting for inactivity threshold of " + inactiveThresholdMilliseconds + "ms or timeout of " + timeoutSeconds + "s (waited " + waitedSeconds + "s)"); } try { diff --git a/utils/src/main/java/org/apache/cloudstack/utils/identity/ManagementServerNode.java b/utils/src/main/java/org/apache/cloudstack/utils/identity/ManagementServerNode.java index fcec7df9fb7c..10f745d04c21 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/identity/ManagementServerNode.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/identity/ManagementServerNode.java @@ -19,8 +19,8 @@ package org.apache.cloudstack.utils.identity; - -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.ComponentLifecycle; @@ -29,7 +29,7 @@ import com.cloud.utils.net.MacAddress; public class ManagementServerNode extends AdapterBase implements SystemIntegrityChecker { - private static final Logger s_logger = Logger.getLogger(ManagementServerNode.class); + private static final Logger LOG = LogFactory.getLogger(ManagementServerNode.class); private static final long s_nodeId = MacAddress.getMacAddress().toLong(); @@ -53,7 +53,7 @@ public boolean start() { try { check(); } catch (Exception e) { - s_logger.error("System integrity check exception", e); + LOG.error("System integrity check exception", e); System.exit(1); } return true; diff --git a/utils/src/main/java/org/apache/cloudstack/utils/imagestore/ImageStoreUtil.java b/utils/src/main/java/org/apache/cloudstack/utils/imagestore/ImageStoreUtil.java index e754a8e1d524..7cd20b383934 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/imagestore/ImageStoreUtil.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/imagestore/ImageStoreUtil.java @@ -20,10 +20,11 @@ import com.cloud.utils.script.Script; import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; public class ImageStoreUtil { - public static final Logger s_logger = Logger.getLogger(ImageStoreUtil.class.getName()); + public static final Logger LOG = LogFactory.getLogger(ImageStoreUtil.class); public static String generatePostUploadUrl(String ssvmUrlDomain, String ipAddress, String uuid) { String hostname = ipAddress; @@ -51,38 +52,38 @@ public static String checkTemplateFormat(String path, String uripath) { // vmdk if ((output.contains("VMware") || output.contains("data")) && isCorrectExtension(uripath, "vmdk")) { - s_logger.debug("File at path " + path + " looks like a vmware image :" + output); + LOG.debug("File at path " + path + " looks like a vmware image :" + output); return ""; } // raw if ((output.contains("x86 boot") || output.contains("data")) && (isCorrectExtension(uripath, "raw") || isCorrectExtension(uripath, "img"))) { - s_logger.debug("File at path " + path + " looks like a raw image :" + output); + LOG.debug("File at path " + path + " looks like a raw image :" + output); return ""; } // qcow2 if (output.contains("QEMU QCOW") && isCorrectExtension(uripath, "qcow2")) { - s_logger.debug("File at path " + path + " looks like QCOW2 : " + output); + LOG.debug("File at path " + path + " looks like QCOW2 : " + output); return ""; } // vhd if (output.contains("Microsoft Disk Image") && (isCorrectExtension(uripath, "vhd") || isCorrectExtension(uripath, "vhdx"))) { - s_logger.debug("File at path " + path + " looks like vhd : " + output); + LOG.debug("File at path " + path + " looks like vhd : " + output); return ""; } // ova if (output.contains("POSIX tar") && isCorrectExtension(uripath, "ova")) { - s_logger.debug("File at path " + path + " looks like ova : " + output); + LOG.debug("File at path " + path + " looks like ova : " + output); return ""; } //lxc if (output.contains("POSIX tar") && isCorrectExtension(uripath, "tar")) { - s_logger.debug("File at path " + path + " looks like just tar : " + output); + LOG.debug("File at path " + path + " looks like just tar : " + output); return ""; } if ((output.startsWith("ISO 9660") || output.startsWith("DOS/MBR")) && isCorrectExtension(uripath, "iso")) { - s_logger.debug("File at path " + path + " looks like an iso : " + output); + LOG.debug("File at path " + path + " looks like an iso : " + output); return ""; } return output; diff --git a/utils/src/main/java/com/cloud/utils/log/CglibThrowableRenderer.java b/utils/src/main/java/org/apache/cloudstack/utils/log/CglibThrowableRenderer.java similarity index 96% rename from utils/src/main/java/com/cloud/utils/log/CglibThrowableRenderer.java rename to utils/src/main/java/org/apache/cloudstack/utils/log/CglibThrowableRenderer.java index 9178c805536c..293d030f8a16 100644 --- a/utils/src/main/java/com/cloud/utils/log/CglibThrowableRenderer.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/log/CglibThrowableRenderer.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.utils.log; +package org.apache.cloudstack.utils.log; import java.util.ArrayList; import java.util.List; @@ -33,7 +33,7 @@ * simply override doRender. Not sure what the developers are thinking there * making it final. * - * + * * into log4j.xml. * */ diff --git a/utils/src/main/java/org/apache/cloudstack/utils/log/Level.java b/utils/src/main/java/org/apache/cloudstack/utils/log/Level.java new file mode 100644 index 000000000000..818d0c8adbe3 --- /dev/null +++ b/utils/src/main/java/org/apache/cloudstack/utils/log/Level.java @@ -0,0 +1,25 @@ +/* + * 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. + */ +package org.apache.cloudstack.utils.log; + +public class Level extends org.apache.log4j.Level { + protected Level(int level, String levelStr, int syslogEquivalent) { + super(level, levelStr, syslogEquivalent); + } +} diff --git a/utils/src/main/java/org/apache/cloudstack/utils/log/LogFactory.java b/utils/src/main/java/org/apache/cloudstack/utils/log/LogFactory.java new file mode 100644 index 000000000000..06d3ba0aff3d --- /dev/null +++ b/utils/src/main/java/org/apache/cloudstack/utils/log/LogFactory.java @@ -0,0 +1,26 @@ +/* + * 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. + */ +package org.apache.cloudstack.utils.log; + +public class LogFactory { + // for log4j 1.2.x the actual LogFactory is org.apache.log4j.LogManager + public static Logger getLogger(Class klas) { + return new Logger(org.apache.log4j.Logger.getLogger(klas)); + } +} diff --git a/utils/src/main/java/org/apache/cloudstack/utils/log/Logger.java b/utils/src/main/java/org/apache/cloudstack/utils/log/Logger.java new file mode 100644 index 000000000000..40529e8a9533 --- /dev/null +++ b/utils/src/main/java/org/apache/cloudstack/utils/log/Logger.java @@ -0,0 +1,84 @@ +/* + * 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. + */ +package org.apache.cloudstack.utils.log; + +/** + * wrapper class for the logging functionality of the log library in use + */ +public class Logger { + private org.apache.log4j.Logger logger; + public Logger(org.apache.log4j.Logger logger) { + this.logger = logger; + } + + // log simple strings + public void log(Level p, String entry) { + logger.log(p, entry); + } + + public void error(String s) { + logger.log(Level.ERROR, s); + } + + public void warn(String s) { + logger.log(Level.WARN, s); + } + + public void info(String s) { + logger.log(Level.INFO, s); + } + + public void debug(String s) { + logger.log(Level.DEBUG, s); + } + + public void trace(String s) { + logger.log(Level.TRACE, s); + } + + // log string with exceptions + public void error(String s, Throwable e) { + logger.error(s, e); + } + + public void warn(String s, Throwable e) { + logger.warn(s, e); + } + + public void info(String s, Throwable e) { + logger.info(s, e); + } + + public void debug(String s, Throwable e) { + logger.debug(s, e); + } + + // level checks + public boolean isEnabledFor(Level p) { + return logger.isEnabledFor(p); + } + + public boolean isDebugEnabled() { + return logger.isEnabledFor(Level.DEBUG); + } + + public boolean isTraceEnabled() { + return logger.isEnabledFor(Level.TRACE); + } +} diff --git a/utils/src/main/java/org/apache/cloudstack/utils/process/ProcessRunner.java b/utils/src/main/java/org/apache/cloudstack/utils/process/ProcessRunner.java index c8ea6bf59a46..d48260fb83b9 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/process/ProcessRunner.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/process/ProcessRunner.java @@ -22,7 +22,8 @@ import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.io.CharStreams; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.joda.time.Duration; import java.io.IOException; @@ -36,7 +37,7 @@ import java.util.concurrent.TimeoutException; public final class ProcessRunner { - public static final Logger LOG = Logger.getLogger(ProcessRunner.class); + public static final Logger LOG = LogFactory.getLogger(ProcessRunner.class); // Default maximum timeout of 5 minutes for any command public static final Duration DEFAULT_MAX_TIMEOUT = new Duration(5 * 60 * 1000); @@ -112,4 +113,4 @@ public Integer call() throws Exception { } return new ProcessResult(stdOutput, stdError, retVal); } -} \ No newline at end of file +} diff --git a/utils/src/main/java/org/apache/cloudstack/utils/security/CertUtils.java b/utils/src/main/java/org/apache/cloudstack/utils/security/CertUtils.java index d357d6d0528e..19b38dba9081 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/security/CertUtils.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/security/CertUtils.java @@ -45,7 +45,8 @@ import javax.security.auth.x500.X500Principal; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.bouncycastle.asn1.ASN1Encodable; import org.bouncycastle.asn1.DERSequence; import org.bouncycastle.asn1.x500.X500Name; @@ -77,7 +78,7 @@ public class CertUtils { - private static final Logger LOG = Logger.getLogger(CertUtils.class); + private static final Logger LOG = LogFactory.getLogger(CertUtils.class); public static KeyPair generateRandomKeyPair(final int keySize) throws NoSuchProviderException, NoSuchAlgorithmException { Security.addProvider(new BouncyCastleProvider()); diff --git a/utils/src/main/java/org/apache/cloudstack/utils/security/SSLUtils.java b/utils/src/main/java/org/apache/cloudstack/utils/security/SSLUtils.java index 8016f5a1916a..faad6c34988a 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/security/SSLUtils.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/security/SSLUtils.java @@ -19,7 +19,8 @@ package org.apache.cloudstack.utils.security; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import javax.net.ssl.SSLContext; import java.security.NoSuchAlgorithmException; @@ -29,7 +30,7 @@ import java.util.Set; public class SSLUtils { - public static final Logger s_logger = Logger.getLogger(SSLUtils.class); + public static final Logger LOG = LogFactory.getLogger(SSLUtils.class); public static String[] getSupportedProtocols(String[] protocols) { Set set = new HashSet(); diff --git a/utils/src/main/java/org/apache/cloudstack/utils/security/SecureSSLSocketFactory.java b/utils/src/main/java/org/apache/cloudstack/utils/security/SecureSSLSocketFactory.java index fa9d492d8d14..3d4d1cd3b431 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/security/SecureSSLSocketFactory.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/security/SecureSSLSocketFactory.java @@ -19,7 +19,8 @@ package org.apache.cloudstack.utils.security; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import javax.net.ssl.KeyManager; import javax.net.ssl.SSLContext; @@ -36,7 +37,7 @@ public class SecureSSLSocketFactory extends SSLSocketFactory { - public static final Logger s_logger = Logger.getLogger(SecureSSLSocketFactory.class); + public static final Logger LOG = LogFactory.getLogger(SecureSSLSocketFactory.class); private SSLContext _sslContext; public SecureSSLSocketFactory() throws NoSuchAlgorithmException { @@ -67,7 +68,7 @@ public String[] getSupportedCipherSuites() { try { ciphers = SSLUtils.getSupportedCiphers(); } catch (NoSuchAlgorithmException e) { - s_logger.error("SecureSSLSocketFactory::getDefaultCipherSuites found no cipher suites"); + LOG.error("SecureSSLSocketFactory::getDefaultCipherSuites found no cipher suites"); } return ciphers; } @@ -121,4 +122,4 @@ public Socket createSocket(InetAddress address, int port, InetAddress localAddre } return socket; } -} \ No newline at end of file +} diff --git a/utils/src/test/java/com/cloud/utils/ScriptTest.java b/utils/src/test/java/com/cloud/utils/ScriptTest.java index 99059bf926ca..fe35b365522d 100644 --- a/utils/src/test/java/com/cloud/utils/ScriptTest.java +++ b/utils/src/test/java/com/cloud/utils/ScriptTest.java @@ -23,7 +23,7 @@ import java.io.IOException; import org.apache.commons.lang.SystemUtils; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; import org.junit.Assert; import org.junit.Assume; import org.junit.Ignore; diff --git a/utils/src/test/java/com/cloud/utils/TestProfiler.java b/utils/src/test/java/com/cloud/utils/TestProfiler.java index 0e681751330b..d7a893abfb09 100644 --- a/utils/src/test/java/com/cloud/utils/TestProfiler.java +++ b/utils/src/test/java/com/cloud/utils/TestProfiler.java @@ -94,4 +94,4 @@ public void testProfilerNoStop() { Assert.assertTrue(pf.getDurationInMillis() == expectedAnswer); Assert.assertFalse(pf.isStopped()); } -} \ No newline at end of file +} diff --git a/utils/src/test/java/com/cloud/utils/UuidUtilsTest.java b/utils/src/test/java/com/cloud/utils/UuidUtilsTest.java index 2ef6bbd25d53..24c3301bc1d9 100644 --- a/utils/src/test/java/com/cloud/utils/UuidUtilsTest.java +++ b/utils/src/test/java/com/cloud/utils/UuidUtilsTest.java @@ -39,4 +39,4 @@ public void testValidateUUIDFail() throws Exception { assertFalse(UuidUtils.validateUUID(serviceUuid)); } -} \ No newline at end of file +} diff --git a/utils/src/test/java/com/cloud/utils/crypto/EncryptionSecretKeyCheckerTest.java b/utils/src/test/java/com/cloud/utils/crypto/EncryptionSecretKeyCheckerTest.java index 0f3f05875909..375a21a6f8fd 100644 --- a/utils/src/test/java/com/cloud/utils/crypto/EncryptionSecretKeyCheckerTest.java +++ b/utils/src/test/java/com/cloud/utils/crypto/EncryptionSecretKeyCheckerTest.java @@ -42,4 +42,4 @@ public void testKeyFileDoesNotExists() throws IOException, URISyntaxException { checker.check(properties); } -} \ No newline at end of file +} diff --git a/utils/src/test/java/com/cloud/utils/net/NetUtilsTest.java b/utils/src/test/java/com/cloud/utils/net/NetUtilsTest.java index 173704a712b7..cd8637c6a7af 100644 --- a/utils/src/test/java/com/cloud/utils/net/NetUtilsTest.java +++ b/utils/src/test/java/com/cloud/utils/net/NetUtilsTest.java @@ -37,7 +37,8 @@ import java.util.SortedSet; import java.util.TreeSet; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.junit.Test; import com.cloud.utils.exception.CloudRuntimeException; @@ -47,7 +48,7 @@ public class NetUtilsTest { - private static final Logger s_logger = Logger.getLogger(NetUtilsTest.class); + private static final Logger LOG = LogFactory.getLogger(NetUtilsTest.class); @Test public void testGetRandomIpFromCidrWithSize24() throws Exception { @@ -135,14 +136,14 @@ public void testGetIp6FromRange() { for (int i = 0; i < 5; i++) { final String ip = NetUtils.getIp6FromRange("1234:5678::1-1234:5678::2"); assertThat(ip, anyOf(equalTo("1234:5678::1"), equalTo("1234:5678::2"))); - s_logger.info("IP is " + ip); + LOG.info("IP is " + ip); } String ipString = null; final IPv6Address ipStart = IPv6Address.fromString("1234:5678::1"); final IPv6Address ipEnd = IPv6Address.fromString("1234:5678::ffff:ffff:ffff:ffff"); for (int i = 0; i < 10; i++) { ipString = NetUtils.getIp6FromRange(ipStart.toString() + "-" + ipEnd.toString()); - s_logger.info("IP is " + ipString); + LOG.info("IP is " + ipString); final IPv6Address ip = IPv6Address.fromString(ipString); assertThat(ip, greaterThanOrEqualTo(ipStart)); assertThat(ip, lessThanOrEqualTo(ipEnd)); diff --git a/utils/src/test/java/com/cloud/utils/testcase/NioTest.java b/utils/src/test/java/com/cloud/utils/testcase/NioTest.java index 0a9deea1a9d6..0fea14ebc31b 100644 --- a/utils/src/test/java/com/cloud/utils/testcase/NioTest.java +++ b/utils/src/test/java/com/cloud/utils/testcase/NioTest.java @@ -27,7 +27,8 @@ import com.cloud.utils.nio.NioServer; import com.cloud.utils.nio.Task; import com.cloud.utils.nio.Task.Type; -import org.apache.log4j.Logger; +import org.apache.cloudstack.utils.log.Logger; +import org.apache.cloudstack.utils.log.LogFactory; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -58,7 +59,7 @@ public class NioTest { - private static final Logger LOGGER = Logger.getLogger(NioTest.class); + private static final Logger LOGGER = LogFactory.getLogger(NioTest.class); // Test should fail in due time instead of looping forever private static final int TESTTIMEOUT = 60000; diff --git a/utils/src/test/java/com/cloud/utils/log/CglibThrowableRendererTest.java b/utils/src/test/java/org/apache/cloudstack/utils/log/CglibThrowableRendererTest.java similarity index 98% rename from utils/src/test/java/com/cloud/utils/log/CglibThrowableRendererTest.java rename to utils/src/test/java/org/apache/cloudstack/utils/log/CglibThrowableRendererTest.java index bf9cfc525f89..6140abdf65b0 100644 --- a/utils/src/test/java/com/cloud/utils/log/CglibThrowableRendererTest.java +++ b/utils/src/test/java/org/apache/cloudstack/utils/log/CglibThrowableRendererTest.java @@ -17,7 +17,7 @@ // under the License. // -package com.cloud.utils.log; +package org.apache.cloudstack.utils.log; import java.lang.reflect.Method; diff --git a/utils/src/test/java/org/apache/cloudstack/utils/security/CertUtilsTest.java b/utils/src/test/java/org/apache/cloudstack/utils/security/CertUtilsTest.java index 1fed17656011..691e7ea0f23f 100644 --- a/utils/src/test/java/org/apache/cloudstack/utils/security/CertUtilsTest.java +++ b/utils/src/test/java/org/apache/cloudstack/utils/security/CertUtilsTest.java @@ -115,4 +115,4 @@ public void testGenerateCertificate() throws Exception { } } -} \ No newline at end of file +} diff --git a/utils/src/test/java/org/apache/cloudstack/utils/security/DigestHelperTest.java b/utils/src/test/java/org/apache/cloudstack/utils/security/DigestHelperTest.java index eac234ef2fc6..17ed09572f5c 100644 --- a/utils/src/test/java/org/apache/cloudstack/utils/security/DigestHelperTest.java +++ b/utils/src/test/java/org/apache/cloudstack/utils/security/DigestHelperTest.java @@ -154,4 +154,4 @@ public void testGetHashValueFromChecksumValueNoPrefixPresent() { } } -//Generated with love by TestMe :) Please report issues and submit feature requests at: http://weirddev.com/forum#!/testme \ No newline at end of file +//Generated with love by TestMe :) Please report issues and submit feature requests at: http://weirddev.com/forum#!/testme diff --git a/utils/src/test/resources/log4j.xml b/utils/src/test/resources/log4j.xml index cdae2fa52e52..f5f0840aba1c 100755 --- a/utils/src/test/resources/log4j.xml +++ b/utils/src/test/resources/log4j.xml @@ -23,7 +23,7 @@ - +