本文整理汇总了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));
}