當前位置: 首頁>>代碼示例>>Java>>正文


Java PropertyConfigurator.configureAndWatch方法代碼示例

本文整理匯總了Java中org.apache.log4j.PropertyConfigurator.configureAndWatch方法的典型用法代碼示例。如果您正苦於以下問題:Java PropertyConfigurator.configureAndWatch方法的具體用法?Java PropertyConfigurator.configureAndWatch怎麽用?Java PropertyConfigurator.configureAndWatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.log4j.PropertyConfigurator的用法示例。


在下文中一共展示了PropertyConfigurator.configureAndWatch方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initLog

import org.apache.log4j.PropertyConfigurator; //導入方法依賴的package包/類
/**
 * Initializes Log4j logging.
 *
 * @throws ServerException thrown if Log4j could not be initialized.
 */
protected void initLog() throws ServerException {
  verifyDir(logDir);
  LogManager.resetConfiguration();
  File log4jFile = new File(configDir, name + "-log4j.properties");
  if (log4jFile.exists()) {
    PropertyConfigurator.configureAndWatch(log4jFile.toString(), 10 * 1000); //every 10 secs
    log = LoggerFactory.getLogger(Server.class);
  } else {
    Properties props = new Properties();
    try {
      InputStream is = getResource(DEFAULT_LOG4J_PROPERTIES);
      try {
        props.load(is);
      } finally {
        is.close();
      }
    } catch (IOException ex) {
      throw new ServerException(ServerException.ERROR.S03, DEFAULT_LOG4J_PROPERTIES, ex.getMessage(), ex);
    }
    PropertyConfigurator.configure(props);
    log = LoggerFactory.getLogger(Server.class);
    log.warn("Log4j [{}] configuration file not found, using default configuration from classpath", log4jFile);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:30,代碼來源:Server.java

示例2: initLogging

import org.apache.log4j.PropertyConfigurator; //導入方法依賴的package包/類
private void initLogging(String confDir) {
  if (System.getProperty("log4j.configuration") == null) {
    System.setProperty("log4j.defaultInitOverride", "true");
    boolean fromClasspath = true;
    File log4jConf = new File(confDir, LOG4J_PROPERTIES).getAbsoluteFile();
    if (log4jConf.exists()) {
      PropertyConfigurator.configureAndWatch(log4jConf.getPath(), 1000);
      fromClasspath = false;
    } else {
      ClassLoader cl = Thread.currentThread().getContextClassLoader();
      URL log4jUrl = cl.getResource(LOG4J_PROPERTIES);
      if (log4jUrl != null) {
        PropertyConfigurator.configure(log4jUrl);
      }
    }
    LOG = LoggerFactory.getLogger(KMSWebApp.class);
    LOG.debug("KMS log starting");
    if (fromClasspath) {
      LOG.warn("Log4j configuration file '{}' not found", LOG4J_PROPERTIES);
      LOG.warn("Logging with INFO level to standard output");
    }
  } else {
    LOG = LoggerFactory.getLogger(KMSWebApp.class);
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:26,代碼來源:KMSWebApp.java

示例3: initializeLogging

import org.apache.log4j.PropertyConfigurator; //導入方法依賴的package包/類
public static void initializeLogging()
{
    if (StringUtils.isBlank(System.getProperty("log.file.path")))
    {
        // get the jar file directory, go one step above, and then set to log directory
        String logfilePath = null;
        try
        {
            logfilePath = AbstractJMSClient.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
            logfilePath += File.separator + ".." + File.separator + ".." + File.separator + "log";
            logfilePath = new File(logfilePath).getCanonicalPath();
        }
        catch (Exception e)
        {
            logfilePath = ".";
        }
        System.setProperty("log.file.path", logfilePath);
    }
    if(StringUtils.isBlank(System.getProperty("log.file")))
    {
        System.setProperty("log.file", "jmsclient.log");
    }
    PropertyConfigurator.configure(System.getProperties());

    PropertyConfigurator.configureAndWatch(
            AbstractJMSClient.class.getResource(File.separator + "log4j.properties").getPath(), PROPERTIES_REFRESH);
}
 
開發者ID:nuagenetworks,項目名稱:jmsclient,代碼行數:28,代碼來源:AbstractJMSClient.java

示例4: setLogLevel

import org.apache.log4j.PropertyConfigurator; //導入方法依賴的package包/類
/**
 * Sets the log level for the given logger. If there is no property file to
 * be used, the log level will be set to the value as given in the level
 * parameter.
 * 
 * @param logger
 *            The logger to be modified.
 * @param level
 *            The log level to be set if no property file can be found.
 */
private static void setLogLevel(Log4jLogger logger, Level level) {
    if (logConfigPath != null && new File(logConfigPath).exists()) {
        PropertyConfigurator.configureAndWatch(logConfigPath, 60000);
    } else {
        logger.systemLogger.setLevel(level);
        logger.auditLogger.setLevel(level);

        // used INFO log level as default for the reverse proxy logger
        logger.proxyLogger.setLevel(Level.INFO);

        // all access operations will be logged with info level
        logger.accessLogger.setLevel(Level.INFO);
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:25,代碼來源:LoggerFactory.java

示例5: init

import org.apache.log4j.PropertyConfigurator; //導入方法依賴的package包/類
/**
 * 可以動態修改log級別 載入log4j配置文件
 */
public static void init() {
	PropertyConfigurator.configureAndWatch(System.getProperty("user.dir") + "/conf/log4j.properties", 5000L);
}
 
開發者ID:inspingcc,項目名稱:LibraSock,代碼行數:7,代碼來源:LibraLog.java


注:本文中的org.apache.log4j.PropertyConfigurator.configureAndWatch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。