当前位置: 首页>>代码示例>>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;未经允许,请勿转载。