• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FileWatchdog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JavaType类代码示例发布时间:2022-05-22
下一篇:
Java Subscription类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap