當前位置: 首頁>>代碼示例>>Java>>正文


Java Logger.setAdditivity方法代碼示例

本文整理匯總了Java中org.apache.log4j.Logger.setAdditivity方法的典型用法代碼示例。如果您正苦於以下問題:Java Logger.setAdditivity方法的具體用法?Java Logger.setAdditivity怎麽用?Java Logger.setAdditivity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.log4j.Logger的用法示例。


在下文中一共展示了Logger.setAdditivity方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testAppendInClose

import org.apache.log4j.Logger; //導入方法依賴的package包/類
@Test
public void testAppendInClose() throws Exception {
  final ContainerLogAppender claAppender = new ContainerLogAppender();
  claAppender.setName("testCLA");
  claAppender.setLayout(new PatternLayout("%-5p [%t]: %m%n"));
  claAppender.setContainerLogDir("target/testAppendInClose/logDir");
  claAppender.setContainerLogFile("syslog");
  claAppender.setTotalLogFileSize(1000);
  claAppender.activateOptions();
  final Logger claLog = Logger.getLogger("testAppendInClose-catergory");
  claLog.setAdditivity(false);
  claLog.addAppender(claAppender);
  claLog.info(new Object() {
    public String toString() {
      claLog.info("message1");
      return "return message1";
    }
  });
  claAppender.close();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:TestContainerLogAppender.java

示例2: getLogger

import org.apache.log4j.Logger; //導入方法依賴的package包/類
/**
 * 
 * @param prop
 * @param clazz
 * @return
 */
public static Logger getLogger(Properties prop, Class<?> clazz) {
    Logger LOG = Logger.getLogger(clazz);
    String appName = PropertiesUtils.getRequiredProperty(prop, PropertiesUtils.APP_NAME);
    String fileDir = PropertiesUtils.getRequiredProperty(prop, PropertiesUtils.LOG_DIR);
    String patternLayout = PropertiesUtils.getRequiredProperty(prop,
            PropertiesUtils.LOG_PATTERN);
    String level = PropertiesUtils.getRequiredProperty(prop, PropertiesUtils.LOG_LEVEL);
    LOG.setLevel(Level.toLevel(level, Level.INFO));
    DailyRollingFileAppender rollingAppender = new DailyRollingFileAppender();
    rollingAppender.setFile(fileDir + "/" + appName + ".log");
    rollingAppender.setLayout(new PatternLayout(patternLayout));
    rollingAppender.setDatePattern("'.'yyyy-MM-dd");
    rollingAppender.activateOptions();
    LOG.addAppender(rollingAppender);
    LOG.setAdditivity(false);
    return LOG;
}
 
開發者ID:sap-nocops,項目名稱:Jerkoff,代碼行數:24,代碼來源:LogUtils.java

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

示例4: getLogger

import org.apache.log4j.Logger; //導入方法依賴的package包/類
/**
    * 
    * Get logger for logging execution status of the running job
    * 
    * @param jobID
    * @param fileLogLocation
    * @return {@link Logger}
    */
public Logger getLogger(String jobID,String fileLogLocation) {
	
	if (executionTrackingLoggers.containsKey(jobID)) {
		return executionTrackingLoggers.get(jobID);
	}
	
	//creates pattern layout
	PatternLayout layout = new PatternLayout();
	layout.setConversionPattern("%m%n");
	
	//create file appender
	FileAppender fileAppender = new FileAppender();
	fileAppender.setFile(fileLogLocation);
	fileAppender.setLayout(layout);
	fileAppender.activateOptions();
	//configures the root logger
	
	Logger logger = Logger.getLogger(jobID);
	logger.setLevel(Level.DEBUG);
	logger.addAppender(fileAppender);
	logger.getRootLogger().setAdditivity(false);
	logger.setAdditivity(false);
	executionTrackingLoggers.put(jobID, logger);
	
       return logger;
   }
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:35,代碼來源:ExecutionTrackingLogger.java

示例5: addLogAppendersFromRoot

import org.apache.log4j.Logger; //導入方法依賴的package包/類
static void addLogAppendersFromRoot(Logger zipkinLogger) {
  zipkinLogger.setAdditivity(false);
  for (Enumeration e = Logger.getRootLogger().getAllAppenders(); e.hasMoreElements(); ) {
    zipkinLogger.addAppender((Appender) e.nextElement());
  }
}
 
開發者ID:openzipkin,項目名稱:zipkin-sparkstreaming,代碼行數:7,代碼來源:LogInitializer.java


注:本文中的org.apache.log4j.Logger.setAdditivity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。