当前位置: 首页>>代码示例>>Java>>正文


Java FileWatchdog类代码示例

本文整理汇总了Java中org.apache.log4j.helpers.FileWatchdog的典型用法代码示例。如果您正苦于以下问题:Java FileWatchdog类的具体用法?Java FileWatchdog怎么用?Java FileWatchdog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileWatchdog类属于org.apache.log4j.helpers包,在下文中一共展示了FileWatchdog类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testConfigDirLog4jConfig

import org.apache.log4j.helpers.FileWatchdog; //导入依赖的package包/类
@Test
public void testConfigDirLog4jConfig() throws IOException {
  RuntimeInfo runtimeInfo = Mockito.mock(RuntimeInfo.class);
  File configDir = new File("target", UUID.randomUUID().toString());
  Assert.assertTrue(configDir.mkdirs());
  InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("log4j.properties");
  OutputStream os = new FileOutputStream(new File(configDir, "log4j.properties"));
  IOUtils.copy(is, os);
  is.close();
  os.close();
  Mockito.when(runtimeInfo.getConfigDir()).thenReturn(configDir.getAbsolutePath());
  Mockito.when(runtimeInfo.getLog4jPropertiesFileName()).thenReturn("log4j.properties");
  new LogConfigurator(runtimeInfo).configure();
  Mockito.verify(runtimeInfo, Mockito.times(1)).getConfigDir();
  boolean foundFileWatcher = false;
  for (Thread thread : Thread.getAllStackTraces().keySet()) {
    foundFileWatcher |= (thread instanceof FileWatchdog);
  }
  Assert.assertTrue(foundFileWatcher);
  Mockito.verify(runtimeInfo, Mockito.times(1)).setAttribute(Mockito.eq(RuntimeInfo.LOG4J_CONFIGURATION_URL_ATTR),
                                                             Mockito.any());
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:23,代码来源:TestLogConfigurator.java

示例2: setConfiguration

import org.apache.log4j.helpers.FileWatchdog; //导入依赖的package包/类
/**
 * 获取配置信息
 */
@Override
public void setConfiguration(Configuration cfg)
		throws ConfigurationException {
	String config = cfg.get("config");
	long watch = cfg.getLong("watch");
	this.logName = cfg.get("log-name");
	if (watch == 0)
		watch = FileWatchdog.DEFAULT_DELAY;
	if ((config != null) && (!config.trim().equals(""))) {
		DOMConfigurator.configureAndWatch(config, watch);
	}
	setLevel(cfg.get("priority"));
}
 
开发者ID:warmsheep,项目名称:VirtualEncoder,代码行数:17,代码来源:Log4jListener.java

示例3: cleanUp

import org.apache.log4j.helpers.FileWatchdog; //导入依赖的package包/类
@After
public void cleanUp() throws Exception {
  System.getProperties().remove("log4j.configuration");
  System.getProperties().remove("log4j.defaultInitOverride");
  for (Thread thread : Thread.getAllStackTraces().keySet()) {
    if (thread instanceof FileWatchdog) {
      Field interrupted = ((Class)thread.getClass().getGenericSuperclass()).getDeclaredField("interrupted");
      interrupted.setAccessible(true);
      interrupted.set(thread, true);
      thread.interrupt();
    }
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:14,代码来源:TestLogConfigurator.java

示例4: testClasspathLog4jConfig

import org.apache.log4j.helpers.FileWatchdog; //导入依赖的package包/类
@Test
public void testClasspathLog4jConfig() {
  RuntimeInfo runtimeInfo = Mockito.mock(RuntimeInfo.class);
  File configDir = new File("target", UUID.randomUUID().toString());
  Assert.assertTrue(configDir.mkdirs());
  Mockito.when(runtimeInfo.getConfigDir()).thenReturn(configDir.getAbsolutePath());
  Mockito.when(runtimeInfo.getLog4jPropertiesFileName()).thenReturn("log4j.properties");
  new LogConfigurator(runtimeInfo).configure();
  Mockito.verify(runtimeInfo, Mockito.times(1)).getConfigDir();
  for (Thread thread : Thread.getAllStackTraces().keySet()) {
   Assert.assertFalse(thread instanceof FileWatchdog);
  }
  Mockito.verify(runtimeInfo, Mockito.times(1)).setAttribute(Mockito.eq(RuntimeInfo.LOG4J_CONFIGURATION_URL_ATTR),
                                                             Mockito.any());
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:16,代码来源:TestLogConfigurator.java

示例5: configureAndWatch

import org.apache.log4j.helpers.FileWatchdog; //导入依赖的package包/类
/**
   Like {@link #configureAndWatch(String, long)} except that the
   default delay as defined by {@link FileWatchdog#DEFAULT_DELAY} is
   used. 

   @param configFilename A log4j configuration file in XML format.

*/
static
public
void configureAndWatch(String configFilename) {
  configureAndWatch(configFilename, FileWatchdog.DEFAULT_DELAY);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:14,代码来源:DOMConfigurator.java

示例6: configureAndWatch

import org.apache.log4j.helpers.FileWatchdog; //导入依赖的package包/类
/**
   Like {@link #configureAndWatch(String, long)} except that the
   default delay as defined by {@link FileWatchdog#DEFAULT_DELAY} is
   used.

   @param configFilename A file in key=value format.

*/
static
public
void configureAndWatch(String configFilename) {
  configureAndWatch(configFilename, FileWatchdog.DEFAULT_DELAY);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:14,代码来源:PropertyConfigurator.java


注:本文中的org.apache.log4j.helpers.FileWatchdog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。