• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StatusListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ch.qos.logback.core.status.StatusListener的典型用法代码示例。如果您正苦于以下问题:Java StatusListener类的具体用法?Java StatusListener怎么用?Java StatusListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StatusListener类属于ch.qos.logback.core.status包,在下文中一共展示了StatusListener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: beforeLogSystemInit

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
@Before
public void beforeLogSystemInit() throws IOException, InterruptedException {

    kafka = TestKafka.createTestKafka(1);

    loggerContext = new LoggerContext();
    loggerContext.putProperty("brokers.list", kafka.getBrokerList());
    loggerContext.getStatusManager().add(new StatusListener() {
        @Override
        public void addStatusEvent(Status status) {
            if (status.getEffectiveLevel() > Status.INFO) {
                System.err.println(status.toString());
                if (status.getThrowable() != null) {
                    collector.addError(status.getThrowable());
                } else {
                    collector.addError(new RuntimeException("StatusManager reported warning: "+status.toString()));
                }
            } else {
                System.out.println(status.toString());
            }
        }
    });
    loggerContext.putProperty("HOSTNAME","localhost");

    unit = new KafkaAppender<ILoggingEvent>();
    final PatternLayout patternLayout = new PatternLayout();
    patternLayout.setPattern("%msg");
    patternLayout.setContext(loggerContext);
    patternLayout.start();
    unit.setEncoder(new LayoutKafkaMessageEncoder(patternLayout, Charset.forName("UTF-8")));
    unit.setTopic("logs");
    unit.setName("TestKafkaAppender");
    unit.setContext(loggerContext);
    unit.addProducerConfigValue(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBrokerList());
    unit.setKeyingStrategy(new RoundRobinKeyingStrategy());
}
 
开发者ID:wngn123,项目名称:wngn-jms-kafka,代码行数:37,代码来源:KafkaAppenderIT.java


示例2: resetStatusListeners

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
private void resetStatusListeners() {
    StatusManager sm = this.getStatusManager();
    Iterator i$ = sm.getCopyOfStatusListenerList().iterator();

    while(i$.hasNext()) {
        StatusListener sl = (StatusListener)i$.next();
        sm.remove(sl);
    }

}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:11,代码来源:KonkerLoggerContext.java


示例3: initAndAddListener

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
private static void initAndAddListener(KonkerLoggerContext loggerContext, StatusListener listener) {
    if(listener != null) {
        if(listener instanceof ContextAware) {
            ((ContextAware)listener).setContext(loggerContext);
        }

        if(listener instanceof LifeCycle) {
            ((LifeCycle)listener).start();
        }

        loggerContext.getStatusManager().add(listener);
    }

}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:15,代码来源:KonkerStatusListenerConfigHelper.java


示例4: createListenerPerClassName

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
private static StatusListener createListenerPerClassName(KonkerLoggerContext loggerContext,
                                                         String listenerClass) {
    try {
        return (StatusListener)OptionHelper.instantiateByClassName(listenerClass, StatusListener.class, loggerContext);
    } catch (Exception var3) {
        var3.printStackTrace();
        return null;
    }
}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:10,代码来源:KonkerStatusListenerConfigHelper.java


示例5: fireStatusAddEvent

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
private void fireStatusAddEvent(Status status) {
  synchronized (statusListenerListLock) {
    for (StatusListener sl : statusListenerList) {
      sl.addStatusEvent(status);
    }
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:8,代码来源:BasicStatusManager.java


示例6: add

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
/**
 * This implementation does not allow duplicate installations of OnConsoleStatusListener
 * @param listener
 */
public void add(StatusListener listener) {
  synchronized (statusListenerListLock) {
    if(listener instanceof OnConsoleStatusListener) {
      boolean alreadyPresent =  checkForPresence(statusListenerList, listener.getClass());
      if(alreadyPresent)
        return;
    }
    statusListenerList.add(listener);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:15,代码来源:BasicStatusManager.java


示例7: checkForPresence

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
private boolean checkForPresence(List<StatusListener> statusListenerList, Class<?> aClass) {
  for(StatusListener e: statusListenerList) {
    if(e.getClass() == aClass)
      return true;
  }
  return false;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:8,代码来源:BasicStatusManager.java


示例8: begin

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException {
  inError = false;
  String className = attributes.getValue(CLASS_ATTRIBUTE);
  if (OptionHelper.isEmpty(className)) {
    addError("Missing class name for statusListener. Near ["
            + name + "] line " + getLineNumber(ec));
    inError = true;
    return;
  }

  try {
    statusListener = (StatusListener) OptionHelper.instantiateByClassName(
            className, StatusListener.class, context);
    ec.getContext().getStatusManager().add(statusListener);
    if (statusListener instanceof ContextAware) {
      ((ContextAware) statusListener).setContext(context);
    }
    addInfo("Added status listener of type [" + className + "]");
    ec.pushObject(statusListener);
  } catch (Exception e) {
    inError = true;
    addError(
            "Could not create an StatusListener of type [" + className + "].", e);
    throw new ActionException(e);
  }

}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:28,代码来源:StatusListenerAction.java


示例9: initAndAddListener

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
private static void initAndAddListener(LoggerContext loggerContext, StatusListener listener) {
  if (listener != null) {
    if(listener instanceof ContextAware) // LOGBACK-767
      ((ContextAware) listener).setContext(loggerContext);
    if(listener instanceof LifeCycle)  // LOGBACK-767
      ((LifeCycle) listener).start();
    loggerContext.getStatusManager().add(listener);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:10,代码来源:StatusListenerConfigHelper.java


示例10: createListenerPerClassName

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
private static StatusListener createListenerPerClassName(LoggerContext loggerContext, String listenerClass) {
  try {
    return (StatusListener) OptionHelper.instantiateByClassName(
            listenerClass, StatusListener.class, loggerContext);
  } catch (Exception e) {
    // printing on the console is the best we can do
    e.printStackTrace();
    return null;
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:11,代码来源:StatusListenerConfigHelper.java


示例11: autoStatusListener

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
@Test
public void autoStatusListener() throws JoranException {
  System.setProperty(ContextInitializer.STATUS_LISTENER_CLASS, TrivialStatusListener.class.getName());
  List<StatusListener> statusListenerList = loggerContext.getStatusManager().getCopyOfStatusListenerList();
  assertEquals(0, statusListenerList.size());
  doAutoConfigFromSystemProperties(ClassicTestConstants.INPUT_PREFIX + "autoConfig.xml");
  statusListenerList = loggerContext.getStatusManager().getCopyOfStatusListenerList();
  assertTrue(statusListenerList.size() +" should be 1", statusListenerList.size() == 1);
  // LOGBACK-767
  TrivialStatusListener tsl = (TrivialStatusListener) statusListenerList.get(0);
  assertTrue("expecting at least one event in list", tsl.list.size() > 0);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:13,代码来源:ContextInitializerTest.java


示例12: autoOnConsoleStatusListener

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
@Test
public void autoOnConsoleStatusListener() throws JoranException {
  System.setProperty(ContextInitializer.STATUS_LISTENER_CLASS,  ContextInitializer.SYSOUT);
  List<StatusListener> sll = loggerContext.getStatusManager().getCopyOfStatusListenerList();
  assertEquals(0, sll.size());
  doAutoConfigFromSystemProperties(ClassicTestConstants.INPUT_PREFIX + "autoConfig.xml");
  sll = loggerContext.getStatusManager().getCopyOfStatusListenerList();
  assertTrue(sll.size() +" should be 1", sll.size() == 1);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:10,代码来源:ContextInitializerTest.java


示例13: remove

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
public void remove(StatusListener listener) {
  synchronized (statusListenerListLock) {
    statusListenerList.remove(listener);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:6,代码来源:BasicStatusManager.java


示例14: getCopyOfStatusListenerList

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
public List<StatusListener> getCopyOfStatusListenerList() {
  synchronized (statusListenerListLock) {
    return new ArrayList<StatusListener>(statusListenerList);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:6,代码来源:BasicStatusManager.java


示例15: add

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
public void add(StatusListener listener) {
  throw new UnsupportedOperationException();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:4,代码来源:MockContext.java


示例16: remove

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
public void remove(StatusListener listener) {
  throw new UnsupportedOperationException();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:4,代码来源:MockContext.java


示例17: getCopyOfStatusListenerList

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
public List<StatusListener> getCopyOfStatusListenerList() {
  throw new UnsupportedOperationException();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:4,代码来源:MockContext.java


示例18: addStatusListener

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
void addStatusListener(StatusListener statusListener) {
  StatusManager sm = loggerContext.getStatusManager();
  sm.add(statusListener);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:5,代码来源:JMXConfigurator.java


示例19: removeStatusListener

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
void removeStatusListener(StatusListener statusListener) {
  StatusManager sm = loggerContext.getStatusManager();
  sm.remove(statusListener);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:5,代码来源:JMXConfigurator.java


示例20: resetStatusListeners

import ch.qos.logback.core.status.StatusListener; //导入依赖的package包/类
private void resetStatusListeners() {
  StatusManager sm = getStatusManager();
  for (StatusListener sl : sm.getCopyOfStatusListenerList()) {
    sm.remove(sl);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:7,代码来源:LoggerContext.java



注:本文中的ch.qos.logback.core.status.StatusListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CloseableReferenceCount类代码示例发布时间:2022-05-22
下一篇:
Java OWLFacet类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap