當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。