当前位置: 首页>>代码示例>>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;未经允许,请勿转载。