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


Java PropertyConfigurator.configure方法代码示例

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


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

示例1: 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

示例2: 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

示例3: configureLogging

import org.apache.log4j.PropertyConfigurator; //导入方法依赖的package包/类
private static void configureLogging(Properties properties) {
       PropertyConfigurator.configure(properties);
       
       Logger log = Logger.getRootLogger();
       log.info("-----------------------------------------------------------------------");
       log.info("UniTime Log File");
       log.info("");
       log.info("Created: " + new Date());
       log.info("");
       log.info("System info:");
       log.info("System:      " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch"));
       log.info("CPU:         " + System.getProperty("sun.cpu.isalist") + " endian:" + System.getProperty("sun.cpu.endian") + " encoding:" + System.getProperty("sun.io.unicode.encoding"));
       log.info("Java:        " + System.getProperty("java.vendor") + ", " + System.getProperty("java.runtime.name") + " " + System.getProperty("java.runtime.version", System.getProperty("java.version")));
       log.info("User:        " + System.getProperty("user.name"));
       log.info("Timezone:    " + System.getProperty("user.timezone"));
       log.info("Working dir: " + System.getProperty("user.dir"));
       log.info("Classpath:   " + System.getProperty("java.class.path"));
       log.info("Memory:      " + (Runtime.getRuntime().maxMemory() / 1024 / 1024) + " MB");
       log.info("Cores:       " + Runtime.getRuntime().availableProcessors());
       log.info("");
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:22,代码来源:SolverServerImplementation.java

示例4: setUp

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

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

    localLogger = Logger.getLogger(getClass());

    localClient = AmazonKinesisClientBuilder.defaultClient();

    deleteStreamIfExists(streamName);
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:18,代码来源:KinesisAppenderIntegrationTest.java

示例5: 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:naver,项目名称:hadoop,代码行数:26,代码来源:KMSWebApp.java

示例6: setUp

import org.apache.log4j.PropertyConfigurator; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
  originalOut = System.err;
  memOut = new ByteArrayOutputStream();
  filterOut = new FilterOut(memOut);
  capturedOut = new PrintStream(filterOut);
  System.setErr(capturedOut);
  InputStream is =
      ThreadUtil.getResourceAsStream("log4j-kmsaudit.properties");
  PropertyConfigurator.configure(is);
  IOUtils.closeStream(is);

  this.kmsAudit = new KMSAudit(1000);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:TestKMSAudit.java

示例7: main

import org.apache.log4j.PropertyConfigurator; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {
        PropertyConfigurator.configure("conf/log4j.properties");
        final AcountService hello = ProxyFactory.create(AcountService.class, "test", null, null);
        System.out.println("result: " + hello.deal(11L));
        System.out.println("");
        //            System.out.println("result: " + hello.deal(222L));
        //            System.out.println("");

        //            System.out.println("result: " + hello.say("bb"));
        //            System.out.println("");
        //
        //            System.out.println("result: " + hello.say("dd"));
        //            System.out.println("");
        //
        //            System.out.println("result: " + hello.say("ee"));
        //            System.out.println("");
        //
        //            System.out.println("result: " + hello.say("ff"));
        //            System.out.println("");
        //
        //            System.out.println("result: " + hello.say("hh"));
        //            System.out.println("");

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:29,代码来源:ClientTest.java

示例8: main

import org.apache.log4j.PropertyConfigurator; //导入方法依赖的package包/类
public static void main(String args[]) {
    try {
        Properties props = new Properties();
        props.setProperty("log4j.rootLogger", "DEBUG, A1");
        props.setProperty("log4j.appender.A1", "org.apache.log4j.ConsoleAppender");
        props.setProperty("log4j.appender.A1.layout", "org.apache.log4j.PatternLayout");
        props.setProperty("log4j.appender.A1.layout.ConversionPattern","%-5p %c{2}: %m%n");
        props.setProperty("log4j.logger.org.hibernate","INFO");
        props.setProperty("log4j.logger.org.hibernate.cfg","WARN");
        props.setProperty("log4j.logger.org.hibernate.cache.EhCacheProvider","ERROR");
        props.setProperty("log4j.logger.org.unitime.commons.hibernate","INFO");
        props.setProperty("log4j.logger.net","INFO");
        PropertyConfigurator.configure(props);
        
        HibernateUtil.configureHibernate(ApplicationProperties.getProperties());
        
        Session session = Session.getSessionUsingInitiativeYearTerm(
                ApplicationProperties.getProperty("initiative", "PWL"),
                ApplicationProperties.getProperty("year","2013"),
                ApplicationProperties.getProperty("term","Fall")
                );
        if (session==null) {
            sLog.error("Academic session not found, use properties initiative, year, and term to set academic session.");
            System.exit(0);
        } else {
            sLog.info("Session: "+session);
        }
        
        ExamType examType = ExamType.findByReference(ApplicationProperties.getProperty("type", "final"));
        boolean override = "true".equals(ApplicationProperties.getProperty("override", "true"));
        boolean classOnly = "true".equals(ApplicationProperties.getProperty("classOnly", "false"));
        
        doUpdate(session.getUniqueId(), examType.getUniqueId(), override, classOnly, new _RootDAO().getSession());

        HibernateUtil.closeHibernate();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:40,代码来源:ExamResetInstructors.java

示例9: main

import org.apache.log4j.PropertyConfigurator; //导入方法依赖的package包/类
public static void main(String[] args) {
	URL logResource = Thread.currentThread().getContextClassLoader().getResource("config/log4j.properties");
	PropertyConfigurator.configure(logResource);
	try {
		LOG.debug("运行VertX-Generator...");
		launch(args);
		LOG.debug("关闭VertX-Generator!!!");
	} catch (Exception e) {
		LOG.error(e);
	}
}
 
开发者ID:shenzhenMirren,项目名称:vertx-generator,代码行数:12,代码来源:Main.java

示例10: setUp

import org.apache.log4j.PropertyConfigurator; //导入方法依赖的package包/类
@BeforeClass
public static void setUp () {
	PropertyConfigurator.configure("testresource/log4jproperties.txt");
	File outDir = new File(OUT_DIR);
	if (!outDir.exists())
		outDir.mkdir();
}
 
开发者ID:RJMillerLab,项目名称:ibench,代码行数:8,代码来源:AbstractAllScenarioTester.java

示例11: initialize

import org.apache.log4j.PropertyConfigurator; //导入方法依赖的package包/类
private void initialize(String propsName)
throws Exception
{
    URL config = ClassLoader.getSystemResource(propsName);
    PropertyConfigurator.configure(config);

    logger = Logger.getLogger(getClass());

    Logger rootLogger = Logger.getRootLogger();
    appender = (WriterAppender)rootLogger.getAppender("default");

    writer = new StringWriter();
    appender.setWriter(writer);
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:15,代码来源:TestJsonLayout.java

示例12: setUp

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

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

    localLogger = Logger.getLogger(getClass());

    localClient = AWSLogsClientBuilder.defaultClient();

    deleteLogGroupIfExists(logGroupName);
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:18,代码来源:CloudWatchAppenderIntegrationTest.java

示例13: init

import org.apache.log4j.PropertyConfigurator; //导入方法依赖的package包/类
public void init() {
    try {


        InputStream inStreamLog4j = SRIGPRSLowLevel.class.getResourceAsStream("log4j.properties");

        System.out.println("Input Stream = " + inStreamLog4j);

        Properties propertiesLog4j = new Properties();
        try {
            propertiesLog4j.load(inStreamLog4j);
            PropertyConfigurator.configure(propertiesLog4j);
        } catch (IOException e) {
            e.printStackTrace();
            BasicConfigurator.configure();
        }

        logger.debug("log4j configured");

        String lf = System.getProperties().getProperty(LOG_FILE_NAME);
        if (lf != null) {
            logFileName = lf;
        }

        // If already created a print writer then just use it.
        try {
            logger.addAppender(new FileAppender(new SimpleLayout(), logFileName));
        } catch (FileNotFoundException fnfe) {

        }
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }

}
 
开发者ID:SigPloiter,项目名称:SigPloit,代码行数:37,代码来源:SRIGPRSLowLevel.java

示例14: VerifiableLog4jAppender

import org.apache.log4j.PropertyConfigurator; //导入方法依赖的package包/类
public VerifiableLog4jAppender(Properties props, int maxMessages) {
    this.maxMessages = maxMessages;
    PropertyConfigurator.configure(props);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:5,代码来源:VerifiableLog4jAppender.java

示例15: init

import org.apache.log4j.PropertyConfigurator; //导入方法依赖的package包/类
@Override
public void init() throws ServletException {
    super.init();
    PropertyConfigurator
            .configure(getClass().getResourceAsStream("/log4j.properties"));
}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:7,代码来源:InitServlet.java


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