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


Java PropertyConfigurator类代码示例

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


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

示例1: setUp

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
/**
 *  Loads the test-specific Log4J configuration and resets the environment.
 */
public void setUp(String propertiesName)
throws Exception
{
    URL config = ClassLoader.getSystemResource(propertiesName);
    assertNotNull("missing configuration: " + propertiesName, config);

    LogManager.resetConfiguration();
    PropertyConfigurator.configure(config);

    localLogger = Logger.getLogger(getClass());

    runId = String.valueOf(System.currentTimeMillis());
    resourceName = "SNSAppenderIntegrationTest-" + runId;
    System.setProperty("SNSAppenderIntegrationTest.resourceName", resourceName);

    localSNSclient = AmazonSNSClientBuilder.defaultClient();
    localSQSclient = AmazonSQSClientBuilder.defaultClient();
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:22,代码来源:SNSAppenderIntegrationTest.java

示例2: configureLogger

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
/**
 * Configures root logger, either for FILE output or just console.
 */
public static void configureLogger() {
    LogManager.shutdown();
    String logFile;
    if (getConfigBoolean("log.save", false)) {
        logFile = "log4j.file.properties";
    }
    else {
        logFile = "log4j.properties";
    }
    InputStream stream = Utils.class.getClassLoader().getResourceAsStream(logFile);
    if (stream == null) {
        PropertyConfigurator.configure("src/main/resources/" + logFile);
    } else {
        PropertyConfigurator.configure(stream);
    }
    logger.info("Loaded " + logFile);
    try {
        stream.close();
    } catch (IOException e) { }
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:24,代码来源:Utils.java

示例3: main

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
public static void main(String[] args) {
    PropertyConfigurator.configure("conf/log4j.properties");
    Method[] methods = HelloImpl.class.getDeclaredMethods();
    for (Method method : methods) {
        System.out.println(method.getName());
        Class<?>[] param = method.getParameterTypes();
        System.out.println(JSON.toJSONString(param));
        try {
            Method m2 = RMethodUtils.searchMethod(HelloImpl.class, method.getName(), param);
            if (m2 == null) {
                System.out.println("null");
            } else {
                System.out.println(method.getName());
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:20,代码来源:HelloImpl.java

示例4: handleOnChange

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
/**
 * On change event
 */
void handleOnChange(File logFile) {
    try {
        long lastModif = logFile.lastModified();
        if (lastModif > logFileLastModified) {
            logFileLastModified = lastModif;
            logger.debug("Reload log4j configuration from "
                    + logFile.getAbsolutePath());
            new PropertyConfigurator().doConfigure(
                    logFile.getAbsolutePath(),
                    LogManager.getLoggerRepository());
            logFileWarning = false;
        }
    } catch (Exception e) {
        if (!logFileWarning) {
            logFileWarning = true;
            logger.error(logFile.getAbsolutePath(), e);
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:23,代码来源:Initializer.java

示例5: testSlowness

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
@Test(expected = EventDeliveryException.class)
public void testSlowness() throws Throwable {
  ch = new SlowMemoryChannel(2000);
  Configurables.configure(ch, new Context());
  configureSource();
  props.put("log4j.appender.out2.Timeout", "1000");
  props.put("log4j.appender.out2.layout", "org.apache.log4j.PatternLayout");
  props.put("log4j.appender.out2.layout.ConversionPattern",
      "%-5p [%t]: %m%n");
  PropertyConfigurator.configure(props);
  Logger logger = LogManager.getLogger(TestLog4jAppender.class);
  Thread.currentThread().setName("Log4jAppenderTest");
  int level = 10000;
  String msg = "This is log message number" + String.valueOf(1);
  try {
    logger.log(Level.toLevel(level), msg);
  } catch (FlumeException ex) {
    throw ex.getCause();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:TestLog4jAppender.java

示例6: noUiStart

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
public static void noUiStart() throws Exception{
	AppConfig.firstInit();
	prod = AppConfig.getProd();
	appFileUtil = new AppFileUtil();
	if(!appFileUtil.success()){
		System.err.println(appFileUtil.getErrorMessage());
		System.exit(-1);
	}
	// ignore everything else because this means that we're in a jar file, so the app won't work
	// if it doesn't think that we're prod. 
	PropertyConfigurator.configure(appFileUtil.getLog4JFile().getAbsolutePath());
	AppConfig.init();
	
	String defaultLocationString = AppConfig.config.getString(AppConfig.WORLD_LOCATION);
	File defaultLocation = new File(defaultLocationString);
	
	
	defaultLocation.mkdirs();
	String relativePath = new File(".").toURI().relativize(defaultLocation.toURI()).getPath();
	AppConfig.saveDefaultWorldLocation("./" + relativePath);
	
	App.worldFileUtil = new WorldFileUtil(new File(AppConfig.config.getString(AppConfig.WORLD_LOCATION)));
	
	Backend.start();
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:26,代码来源:App.java

示例7: setupLog4j

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
private void setupLog4j(String appName) {

        // InputStream inStreamLog4j = getClass().getResourceAsStream("/log4j.properties");

        String propFileName = appName + ".log4j.properties";
        File f = new File("./" + propFileName);
        if (f.exists()) {

            try {
                InputStream inStreamLog4j = new FileInputStream(f);
                Properties propertiesLog4j = new Properties();

                propertiesLog4j.load(inStreamLog4j);
                PropertyConfigurator.configure(propertiesLog4j);
            } catch (Exception e) {
                e.printStackTrace();
                BasicConfigurator.configure();
            }
        } else {
            BasicConfigurator.configure();
        }

        // logger.setLevel(Level.TRACE);
        logger.debug("log4j configured");

    }
 
开发者ID:RestComm,项目名称:phone-simulator,代码行数:27,代码来源:TesterHost.java

示例8: init

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
public static void init(List<String> locationPatterns) throws Exception {
  if (inited) {
    return;
  }

  synchronized (LOCK) {
    if (inited) {
      return;
    }

    PropertiesLoader loader = new PropertiesLoader(locationPatterns);
    Properties properties = loader.load();
    if (properties.isEmpty()) {
      throw new Exception("can not find resource " + locationPatterns);
    }

    PropertyConfigurator.configure(properties);
    inited = true;

    // 如果最高优先级的文件是在磁盘上,且有写权限,则将merge的结果输出到该目录,方便维护时观察生效的参数
    outputFile(loader.getFoundResList(), properties);
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:24,代码来源:Log4jUtils.java

示例9: init

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
/**
 * Initialization of the servlet. <br>
 *
 * @throws ServletException if an error occurs
 */
public void init() throws ServletException {
	String file = this.getServletContext().getRealPath(this.getInitParameter("log4j"));
	//从web.xml配置读取,名字一定要和web.xml配置一致
	  if(file != null){
	     PropertyConfigurator.configure(file);
	  }
	// Put your code here
	new CrawlerServer(DefaultConfig.serverPort).start();
	try {
		new WebSocket(DefaultConfig.socketPort).start();
	} catch (UnknownHostException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:zrtzrt,项目名称:CrawlerSYS,代码行数:21,代码来源:CrawlerServlet.java

示例10: initConf

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
private void initConf() {
    try {
        String logpath = context.getConfigPath() + File.separator + "log4j.properties";
        PropertyConfigurator.configure(logpath);
        logger.info(String.format("log4j path:%s", logpath));

        String serverpath = context.getConfigPath() + File.separator + "server.properties";
        NettyServerConfig config = GuiceDI.getInstance(NettyServerConfig.class);
        PropertiesHelper pro = new PropertiesHelper(serverpath);
        config.setSelectorThreads(pro.getInt("selectorThreads"));
        config.setWorkerThreads(pro.getInt("workerThreads"));
        config.setListenPort(pro.getInt("server.Port"));
        config.setUsezk(pro.getBoolean("use.zk"));
        config.setZkhosts(pro.getString("zk.hosts"));

        logger.info(JSON.toJSONString(config));

    } catch (Exception e) {
        logger.error("", e);
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:22,代码来源:RPCServer.java

示例11: main

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
public static void main(String... args) throws Exception {
    PropertyConfigurator.configure("D:/log4j.properties");

    try {
        List<Replica> members = Lists.newArrayList();
        members.add(Replica.fromString("localhost:10000"));
        members.add(Replica.fromString("localhost:10002"));
        File logDir = new File("D:/raft1");
        logDir.mkdir();

        // configure the service
        RaftService raft = RaftService.newBuilder().local(Replica.fromString("localhost:10001")).members(members).logDir(logDir).timeout(300).build(new Test2());

        // start this replica
        raft.startAsync().awaitRunning();

    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:22,代码来源:Test2.java

示例12: main

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
public static void main(String... args) throws Exception {
    PropertyConfigurator.configure("D:/log4j.properties");

    try {
        List<Replica> members = Lists.newArrayList();
        members.add(Replica.fromString("localhost:10000"));
        members.add(Replica.fromString("localhost:10001"));
        File logDir = new File("D:/raft2");
        logDir.mkdir();

        // configure the service
        RaftService raft = RaftService.newBuilder().local(Replica.fromString("localhost:10002")).members(members).logDir(logDir).timeout(300).build(new Test3());

        // start this replica
        raft.startAsync().awaitRunning();

        // let's commit some things
        //            for (int i = 0; i < 10; i++) {
        //                raft.commit(new byte[] { 'O', '_', 'o' });
        //            }
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:26,代码来源:Test3.java

示例13: main

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
public static void main(String... args) throws Exception {
    PropertyConfigurator.configure("D:/log4j.properties");

    try {
        List<Replica> members = Lists.newArrayList();
        members.add(Replica.fromString("localhost:10001"));
        members.add(Replica.fromString("localhost:10002"));
        File logDir = new File("D:/raft");
        logDir.mkdir();

        // configure the service
        RaftService raft = RaftService.newBuilder().local(Replica.fromString("localhost:10000")).members(members).logDir(logDir).timeout(300).build(new Test());

        // start this replica
        Service guavaservice = raft.startAsync();
        guavaservice.awaitRunning();

        // let's commit some things
        //            for (int i = 0; i < 10; i++) {
        //                raft.commit(new byte[] { 'O', '_', 'o' });
        //            }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:26,代码来源:Test.java

示例14: main

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
public static void main(String[] args) {
    try {
        RateLimiter limit = RateLimiter.create(100d);
        PropertyConfigurator.configure("conf/log4j.properties");
        while (true) {
            if (limit.tryAcquire()) {
                final HelloCommand command = new HelloCommand();
                //            System.out.println("result: " + command.execute());
                //            System.out.println("");

                Future<String> future = command.queue();
                System.out.println("result: " + future.get());
                System.out.println("");
            }
        }

        //            Observable<String> observe = command.observe();
        //            observe.asObservable().subscribe((result) -> {
        //                System.out.println(result);
        //            });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:25,代码来源:ClientTest.java

示例15: main

import org.apache.log4j.PropertyConfigurator; //导入依赖的package包/类
public static void main(String[] args) {
    try {
        PropertyConfigurator.configure("conf/log4j.properties");
        final Hello hello = ProxyFactory.create(Hello.class, "test", null, null);
        System.out.println("result: " + hello.say("xiaoming"));
        System.out.println("");
        System.out.println("result: " + hello.hi(2));
        System.out.println("");
        //            System.out.println("result: " + hello.hi(2));
        //            System.out.println("");
        //            System.out.println("result: " + hello.hi(2));
        //            System.out.println("");
        //            System.out.println("result: " + hello.hi(2));
        System.out.println("");
        // 
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:20,代码来源:ClientTest.java


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