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


Java Logger.removeAllAppenders方法代碼示例

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


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

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

示例2: enableRingBufferAppender

import org.apache.log4j.Logger; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static void enableRingBufferAppender(Logger logger, int bufferSize) {
    Layout l = null;
    if (LOG.isDebugEnabled())
        LOG.debug(logger + " => " + logger.getAllAppenders());
    for (Object o : CollectionUtil.iterable(logger.getAllAppenders())) {
        Appender a = (Appender)o;
        l = a.getLayout();
    } // FOR
    if (l != null) {
        logger.removeAllAppenders();
        logger.addAppender(new RingBufferAppender(bufferSize));
        Logger.getRootLogger().info("Enabled RingBuffer logging for '" + logger.getName() + "'");
    }        
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:16,代碼來源:RingBufferAppender.java

示例3: logOut

import org.apache.log4j.Logger; //導入方法依賴的package包/類
private String logOut(String message, Throwable throwable) {
  StringWriter writer = new StringWriter();
  Logger logger = createLogger(writer);
  logger.info(message, throwable);
  //remove and close the appender
  logger.removeAllAppenders();
  return writer.toString();
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:9,代碼來源:TestLog4Json.java


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