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


Java ConsoleAppender.doAppend方法代码示例

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


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

示例1: wrongTarget

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@Test
  public void wrongTarget() {
    ConsoleAppender<Object> ca = (ConsoleAppender<Object>) getAppender();
    EchoEncoder<Object> encoder = new EchoEncoder<Object>();
    encoder.setContext(context);
    ca.setContext(context);
    ca.setTarget("foo");
    ca.setEncoder(encoder);
    ca.start();
    ca.doAppend("a");
    StatusChecker checker = new StatusChecker(context);
    //21:28:01,246 + WARN in ch.qos.logback.core.ConsoleAppender[null] - [foo] should be one of [SystemOut, SystemErr]
    //21:28:01,246   |-WARN in ch.qos.logback.core.ConsoleAppender[null] - Using previously set target, System.out by default.
//    StatusPrinter.print(context);

    checker.assertContainsMatch(Status.WARN, "\\[foo\\] should be one of \\[SystemOut, SystemErr\\]");

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

示例2: testBasic

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@org.junit.Test
public void testBasic() {
  ConsoleAppender<Object> ca = (ConsoleAppender<Object>) getAppender();
  ca.setEncoder(new DummyEncoder<Object>());
  ca.start();
  ca.doAppend(new Object());
  assertEquals(DummyLayout.DUMMY, tee.toString());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:9,代码来源:ConsoleAppenderTest.java

示例3: testOpen

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@org.junit.Test
public void testOpen() {
  ConsoleAppender<Object> ca = (ConsoleAppender<Object>) getAppender();
  DummyEncoder<Object> dummyEncoder = new DummyEncoder<Object>();
  dummyEncoder.setFileHeader("open");
  ca.setEncoder(dummyEncoder);
  ca.start();
  ca.doAppend(new Object());
  ca.stop();
  assertEquals("open" + CoreConstants.LINE_SEPARATOR + DummyLayout.DUMMY, tee
      .toString());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:13,代码来源:ConsoleAppenderTest.java

示例4: testClose

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@Test
public void testClose() {
  ConsoleAppender<Object> ca = (ConsoleAppender<Object>) getAppender();
  DummyEncoder<Object> dummyEncoder = new DummyEncoder<Object>();
  dummyEncoder.setFileFooter("CLOSED");
  ca.setEncoder(dummyEncoder);
  ca.start();
  ca.doAppend(new Object());
  ca.stop();
  // ConsoleAppender must keep the underlying stream open.
  // The console is not ours to close.
  assertFalse(tee.isClosed());
  assertEquals(DummyLayout.DUMMY + "CLOSED", tee.toString());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:15,代码来源:ConsoleAppenderTest.java

示例5: changeInConsole

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@Test
public void changeInConsole() {
  ConsoleAppender<Object> ca = (ConsoleAppender<Object>) getAppender();
  EchoEncoder<Object> encoder = new EchoEncoder<Object>();
  ca.setEncoder(encoder);
  ca.start();
  ca.doAppend("a");
  assertEquals("a" + CoreConstants.LINE_SEPARATOR, tee.toString());

  XTeeOutputStream newTee = new XTeeOutputStream(null);
  System.setOut(new PrintStream(newTee));
  ca.doAppend("b");
  assertEquals("b" + CoreConstants.LINE_SEPARATOR, newTee.toString());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:15,代码来源:ConsoleAppenderTest.java

示例6: testUTF16BE

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@Test
public void testUTF16BE() throws UnsupportedEncodingException {
  ConsoleAppender<Object> ca = (ConsoleAppender<Object>) getAppender();
  DummyEncoder<Object> dummyEncoder = new DummyEncoder<Object>();
  String encodingName = "UTF-16BE";
  dummyEncoder.setEncodingName(encodingName);
  ca.setEncoder(dummyEncoder);
  ca.start();
  ca.doAppend(new Object());
  assertEquals(DummyLayout.DUMMY, new String(tee.toByteArray(), encodingName));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:12,代码来源:ConsoleAppenderTest.java


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