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


Java Logger.getRootLogger方法代码示例

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


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

示例1: configureLogging

import org.apache.log4j.Logger; //导入方法依赖的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

示例2: attachPassiveDbAppender

import org.apache.log4j.Logger; //导入方法依赖的package包/类
private void attachPassiveDbAppender(
                                      DbAppenderConfiguration appenderConfiguration,
                                      long timestamp ) {

    // create the new appender
    PassiveDbAppender attachedAppender = new PassiveDbAppender(ThreadsPerCaller.getCaller());

    // calculate the time stamp offset, between the test executor and the agent
    attachedAppender.calculateTimeOffset(timestamp);

    attachedAppender.setAppenderConfig(appenderConfiguration);
    // use a default pattern, as we log in the db
    attachedAppender.setLayout(new PatternLayout("%c{2}: %m%n"));
    attachedAppender.activateOptions();

    // attach the appender to the logging system
    Category log = Logger.getRootLogger();

    log.setLevel(Level.toLevel(appenderConfiguration.getLoggingThreshold().toInt()));
    log.addAppender(attachedAppender);

}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:23,代码来源:AgentConfigurationServiceImpl.java

示例3: syncLogs

import org.apache.log4j.Logger; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static synchronized void syncLogs() {
  // flush standard streams
  //
  System.out.flush();
  System.err.flush();

  // flush flushable appenders
  //
  final Logger rootLogger = Logger.getRootLogger();
  flushAppenders(rootLogger);
  final Enumeration<Logger> allLoggers = rootLogger.getLoggerRepository().
    getCurrentLoggers();
  while (allLoggers.hasMoreElements()) {
    final Logger l = allLoggers.nextElement();
    flushAppenders(l);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TaskLog.java

示例4: init

import org.apache.log4j.Logger; //导入方法依赖的package包/类
/**
 * Initializes the log4j logging with an additional appender which routes the logging to the Eclipse ErrorView.
 */
public static void init() {
	Logger rootLogger = Logger.getRootLogger();

	// # This appender will write to the Eclipse error log. It will ONLY log ERROR and FATAL messages.
	// log4j.appender.eclipse=org.eclipse.xtext.logging.EclipseLogAppender
	EclipseLogAppender eclipseAppender = new EclipseLogAppender();
	eclipseAppender.setName("eclipse");
	rootLogger.addAppender(eclipseAppender);

	// log4j.appender.eclipse.layout=org.apache.log4j.PatternLayout
	// log4j.appender.eclipse.layout.ConversionPattern=%c %x - %m%n
	eclipseAppender.setLayout(new PatternLayout("%c %x - %m%n"));

	// # EclipseLogAppender must not log to the 'eclipse' appender as that would cause a stack overflow!
	// log4j.additivity.org.eclipse.xtext.logging.EclipseLogAppender=false
	// log4j.logger.org.eclipse.xtext.logging.EclipseLogAppender=WARN, default
	Logger eclipseAppenderLogger = Logger.getLogger(EclipseLogAppender.class);
	eclipseAppenderLogger.setAdditivity(false);
	eclipseAppenderLogger.setLevel(Level.WARN);
	Appender defaultAppender = eclipseAppenderLogger.getAppender("default");
	if (eclipseAppenderLogger.getAllAppenders().hasMoreElements()) {
		eclipseAppenderLogger.removeAllAppenders();
	}
	if (defaultAppender != null) {
		eclipseAppenderLogger.addAppender(defaultAppender);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:31,代码来源:N4jsUiLoggingInitializer.java

示例5: readObject

import org.apache.log4j.Logger; //导入方法依赖的package包/类
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  	in.defaultReadObject();
  	String name = (String) in.readObject();
if (name == null) {
	logger = Logger.getRootLogger();
} else {
	logger = Logger.getLogger(name);
}
  }
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:10,代码来源:JSimLogger.java

示例6: setLoggingLevel

import org.apache.log4j.Logger; //导入方法依赖的package包/类
@Override
public void setLoggingLevel(String name, Integer level) {
	sLog.info("Set logging level for " + (name == null ? "root" : name) + " to " + (level == null ? "null" : Level.toLevel(level)));
	Logger logger = (name == null ? Logger.getRootLogger() : Logger.getLogger(name));
	if (level == null)
		logger.setLevel(null);
	else
		logger.setLevel(Level.toLevel(level));
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:10,代码来源:SolverServerImplementation.java

示例7: testChooseTargetWithMoreThanAvailableNodes

import org.apache.log4j.Logger; //导入方法依赖的package包/类
/**
 * In this testcase, it tries to choose more targets than available nodes and
 * check the result. 
 * @throws Exception
 */
@Test
public void testChooseTargetWithMoreThanAvailableNodes() throws Exception {
  // make data node 0 & 1 to be not qualified to choose: not enough disk space
  for(int i=0; i<2; i++) {
    updateHeartbeatWithUsage(dataNodes[i],
        2*HdfsConstants.MIN_BLOCKS_FOR_WRITE*BLOCK_SIZE, 0L,
        (HdfsConstants.MIN_BLOCKS_FOR_WRITE-1)*BLOCK_SIZE, 0L, 0L, 0L, 0, 0);
  }
  
  final LogVerificationAppender appender = new LogVerificationAppender();
  final Logger logger = Logger.getRootLogger();
  logger.addAppender(appender);
  
  // try to choose NUM_OF_DATANODES which is more than actually available
  // nodes.
  DatanodeStorageInfo[] targets = chooseTarget(NUM_OF_DATANODES);
  assertEquals(targets.length, NUM_OF_DATANODES - 2);

  final List<LoggingEvent> log = appender.getLog();
  assertNotNull(log);
  assertFalse(log.size() == 0);
  final LoggingEvent lastLogEntry = log.get(log.size() - 1);
  
  assertTrue(Level.WARN.isGreaterOrEqual(lastLogEntry.getLevel()));
  // Suppose to place replicas on each node but two data nodes are not
  // available for placing replica, so here we expect a short of 2
  assertTrue(((String) lastLogEntry.getMessage()).contains("in need of 2"));

  resetHeartbeatForStorages();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:TestReplicationPolicy.java

示例8: initialize

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

    logger = Logger.getLogger(getClass());

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

    appender.setThreadFactory(new InlineThreadFactory());
    appender.setWriterFactory(new MockCloudWatchWriterFactory(appender));
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:16,代码来源:TestCloudWatchAppender.java

示例9: initialize

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

    logger = Logger.getLogger(getClass());

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

    appender.setThreadFactory(new InlineThreadFactory());
    appender.setWriterFactory(new MockKinesisWriterFactory(appender));
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:16,代码来源:TestKinesisAppender.java

示例10: initialize

import org.apache.log4j.Logger; //导入方法依赖的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

示例11: init

import org.apache.log4j.Logger; //导入方法依赖的package包/类
public void init() {        
        sipStack = null;
        sipFactory = SipFactory.getInstance();
        System.setProperty( "javax.net.ssl.keyStore",  "/Users/vladimirralev/keystore.ImportKey" );
        System.setProperty( "javax.net.ssl.trustStore", "/Users/vladimirralev/keystore.ImportKey" );
        System.setProperty( "javax.net.ssl.keyStorePassword", "importkey" );
        System.setProperty( "javax.net.ssl.keyStoreType", "jks" );
        sipFactory.setPathName("gov.nist");
        Properties properties = new Properties();
        properties.setProperty("javax.sip.STACK_NAME", "shootme");
        // You need 16 for logging traces. 32 for debug + traces.
        // Your code will limp at 32 but it is best for debugging.
        properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "LOG4J");
        Logger root = Logger.getRootLogger();
        root.setLevel(Level.WARN);
        root.addAppender(new ConsoleAppender(
            new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
        properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "false");
        properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "off");        
        properties.setProperty("gov.nist.javax.sip.DEBUG_LOG",
                "shootmedebug.txt");
        properties.setProperty("gov.nist.javax.sip.SERVER_LOG",
        "shootmelog.txt");
        properties.setProperty("gov.nist.javax.sip.TLS_CLIENT_PROTOCOLS",
                "TLSv1");
        properties.setProperty("gov.nist.javax.sip.REENTRANT_LISTENER",
        "true");
        properties.setProperty("gov.nist.javax.sip.THREAD_POOL_SIZE", "4");
        properties.setProperty("gov.nist.javax.sip.RECEIVE_UDP_BUFFER_SIZE", "65536");
        properties.setProperty("gov.nist.javax.sip.SEND_UDP_BUFFER_SIZE", "65536");
        properties.setProperty("gov.nist.javax.sip.TCP_POST_PARSING_THREAD_POOL_SIZE", "12");
        properties.setProperty("gov.nist.javax.sip.CONGESTION_CONTROL_ENABLED", "false");
        properties.setProperty("gov.nist.javax.sip.TLS_CLIENT_AUTH_TYPE", "Disabled");
        
//      properties.setProperty("gov.nist.javax.sip.MESSAGE_PARSER_FACTORY", CharsMsgParserFactory.class.getName());
//		properties.setProperty("gov.nist.javax.sip.TIMER_CLASS_NAME", ScheduledExecutorSipTimer.class.getName());
//      properties.setProperty("gov.nist.javax.sip.TIMER_CLASS_NAME", HashWheelSipTimer.class.getName());
        try {
            // Create SipStack object
            sipStack = sipFactory.createSipStack(properties);
        } catch (PeerUnavailableException e) {
            // could not find
            // gov.nist.jain.protocol.ip.sip.SipStackImpl
            // in the classpath
            e.printStackTrace();
            System.err.println(e.getMessage());
            if (e.getCause() != null)
                e.getCause().printStackTrace();
            System.exit(0);
        }

        try {
            headerFactory = sipFactory.createHeaderFactory();
            addressFactory = sipFactory.createAddressFactory();
            messageFactory = sipFactory.createMessageFactory();
            ListeningPoint lp = sipStack.createListeningPoint("127.0.0.1",
                    myPort, TRANSPORT);

            Shootme listener = this;

            sipProvider = sipStack.createSipProvider(lp);
            sipProvider.addSipListener(listener);

        } catch (Exception ex) {
            ex.printStackTrace();
            usage();
        }

    }
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:70,代码来源:Shootme.java

示例12: runImport

import org.apache.log4j.Logger; //导入方法依赖的package包/类
protected int runImport(String tableName, Configuration sqoopConf,
    boolean sequenceFile) {
  Logger rootLogger = Logger.getRootLogger();
  StringWriter stringWriter = new StringWriter();
  Layout layout = new PatternLayout("%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n");
  WriterAppender writerAppender = new WriterAppender(layout, stringWriter);
  rootLogger.addAppender(writerAppender);

  List<String> sqoopArgs = new ArrayList<String>();

  sqoopArgs.add("import");

  sqoopArgs.add("--direct");

  if (sequenceFile) {
    sqoopArgs.add("--as-sequencefile");
  }

  sqoopArgs.add("--connect");
  sqoopArgs.add(OracleUtils.CONNECT_STRING);

  sqoopArgs.add("--username");
  sqoopArgs.add(OracleUtils.ORACLE_USER_NAME);

  sqoopArgs.add("--password");
  sqoopArgs.add(OracleUtils.ORACLE_USER_PASS);

  sqoopArgs.add("--table");
  sqoopArgs.add(tableName);

  sqoopArgs.add("--target-dir");
  sqoopArgs.add(this.sqoopTargetDirectory);

  sqoopArgs.add("--class-name");
  sqoopArgs.add(getSqoopGenClassName());

  sqoopArgs.add("--bindir");
  sqoopArgs.add(this.sqoopGenLibDirectory);

  sqoopArgs.add("--outdir");
  sqoopArgs.add(this.sqoopGenSrcDirectory);

  if (OracleUtils.NUM_MAPPERS != 0) {
    sqoopArgs.add("--num-mappers");
    sqoopArgs.add(Integer.toString(OracleUtils.NUM_MAPPERS));
  }

  int rowsInTable =
      countTable(tableName, OraOopUtilities.splitOracleStringList(sqoopConf
          .get(OraOopConstants.ORAOOP_IMPORT_PARTITION_LIST)));

  int retCode =
      Sqoop.runTool(sqoopArgs.toArray(new String[sqoopArgs.size()]),
          sqoopConf);
  int rowsImported = 0;
  if (retCode == 0) {
    String logString = stringWriter.toString();
    Pattern pattern =
        Pattern.compile(
            "(INFO mapreduce.ImportJobBase: Retrieved )([0-9]+)( records.)");
    Matcher matcher = pattern.matcher(logString);
    while (matcher.find()) {
      rowsImported = Integer.parseInt(matcher.group(2));
    }
  }
  Assert.assertEquals("Incorrect number of rows imported", rowsInTable,
      rowsImported);
  return retCode;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:70,代码来源:OraOopTestCase.java

示例13: rootLogger

import org.apache.log4j.Logger; //导入方法依赖的package包/类
@Override
protected ESLogger rootLogger() {
    return new Log4jESLogger(null, Logger.getRootLogger());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:Log4jESLoggerFactory.java

示例14: testFilesExceedMaxLockedMemory

import org.apache.log4j.Logger; //导入方法依赖的package包/类
@Test(timeout=600000)
public void testFilesExceedMaxLockedMemory() throws Exception {
  LOG.info("beginning testFilesExceedMaxLockedMemory");

  // Create some test files that will exceed total cache capacity
  final int numFiles = 5;
  final long fileSize = CACHE_CAPACITY / (numFiles-1);

  final Path[] testFiles = new Path[numFiles];
  final HdfsBlockLocation[][] fileLocs = new HdfsBlockLocation[numFiles][];
  final long[] fileSizes = new long[numFiles];
  for (int i=0; i<numFiles; i++) {
    testFiles[i] = new Path("/testFilesExceedMaxLockedMemory-" + i);
    DFSTestUtil.createFile(fs, testFiles[i], fileSize, (short)1, 0xDFAl);
    fileLocs[i] = (HdfsBlockLocation[])fs.getFileBlockLocations(
        testFiles[i], 0, fileSize);
    // Get the file size (sum of blocks)
    long[] sizes = getBlockSizes(fileLocs[i]);
    for (int j=0; j<sizes.length; j++) {
      fileSizes[i] += sizes[j];
    }
  }

  // Cache the first n-1 files
  long total = 0;
  DFSTestUtil.verifyExpectedCacheUsage(0, 0, fsd);
  for (int i=0; i<numFiles-1; i++) {
    setHeartbeatResponse(cacheBlocks(fileLocs[i]));
    total = DFSTestUtil.verifyExpectedCacheUsage(
        rounder.round(total + fileSizes[i]), 4 * (i + 1), fsd);
  }

  // nth file should hit a capacity exception
  final LogVerificationAppender appender = new LogVerificationAppender();
  final Logger logger = Logger.getRootLogger();
  logger.addAppender(appender);
  setHeartbeatResponse(cacheBlocks(fileLocs[numFiles-1]));

  GenericTestUtils.waitFor(new Supplier<Boolean>() {
    @Override
    public Boolean get() {
      int lines = appender.countLinesWithMessage(
          "more bytes in the cache: " +
          DFSConfigKeys.DFS_DATANODE_MAX_LOCKED_MEMORY_KEY);
      return lines > 0;
    }
  }, 500, 30000);
  // Also check the metrics for the failure
  assertTrue("Expected more than 0 failed cache attempts",
      fsd.getNumBlocksFailedToCache() > 0);

  // Uncache the n-1 files
  int curCachedBlocks = 16;
  for (int i=0; i<numFiles-1; i++) {
    setHeartbeatResponse(uncacheBlocks(fileLocs[i]));
    long uncachedBytes = rounder.round(fileSizes[i]);
    total -= uncachedBytes;
    curCachedBlocks -= uncachedBytes / BLOCK_SIZE;
    DFSTestUtil.verifyExpectedCacheUsage(total, curCachedBlocks, fsd);
  }
  LOG.info("finishing testFilesExceedMaxLockedMemory");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:63,代码来源:TestFsDatasetCache.java

示例15: init

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

            
            SipFactory sipFactory = null;
            sipStack = null;
            sipFactory = SipFactory.getInstance();
            sipFactory.setPathName("gov.nist");
            Properties properties = new Properties();
            properties.setProperty("javax.sip.STACK_NAME", "shootme");
            // You need 16 for logging traces. 32 for debug + traces.
            // Your code will limp at 32 but it is best for debugging.
            properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "LOG4J");
            Logger root = Logger.getRootLogger();
            root.setLevel(Level.WARN);
            root.addAppender(new ConsoleAppender(
                new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
            properties.setProperty("gov.nist.javax.sip.DEBUG_LOG",
                    "shootmedebug.txt");
            properties.setProperty("gov.nist.javax.sip.SERVER_LOG",
                    "shootmelog.txt");
            properties.setProperty("gov.nist.javax.sip.AUTOMATIC_DIALOG_ERROR_HANDLING", "false");
            properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "off");

            properties.setProperty("gov.nist.javax.sip.TCP_POST_PARSING_THREAD_POOL_SIZE", "20");
            if(System.getProperty("enableNIO") != null && System.getProperty("enableNIO").equalsIgnoreCase("true")) {
            	properties.setProperty("gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY", NioMessageProcessorFactory.class.getName());
            }
            try {
                // Create SipStack object
                sipStack = sipFactory.createSipStack(properties);
                System.out.println("sipStack = " + sipStack);
            } catch (PeerUnavailableException e) {
                // could not find
                // gov.nist.jain.protocol.ip.sip.SipStackImpl
                // in the classpath
                e.printStackTrace();
                System.err.println(e.getMessage());
                if (e.getCause() != null)
                    e.getCause().printStackTrace();
                //System.exit(0);
            }

            try {
                headerFactory = sipFactory.createHeaderFactory();
                addressFactory = sipFactory.createAddressFactory();
                messageFactory = sipFactory.createMessageFactory();
                ListeningPoint lp = sipStack.createListeningPoint("127.0.0.1",
                        myPort, "tcp");

                Shootme listener = this;

                sipProvider = sipStack.createSipProvider(lp);
                System.out.println("udp provider " + sipProvider);
                sipProvider.addSipListener(listener);

            } catch (Exception ex) {
                ex.printStackTrace();
                fail("Unexpected exception");
            }

        }
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:62,代码来源:TcpMultiThreadDeadlockTest.java


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