本文整理匯總了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\\]");
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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));
}