本文整理匯總了Java中org.apache.log4j.WriterAppender.setLayout方法的典型用法代碼示例。如果您正苦於以下問題:Java WriterAppender.setLayout方法的具體用法?Java WriterAppender.setLayout怎麽用?Java WriterAppender.setLayout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.log4j.WriterAppender
的用法示例。
在下文中一共展示了WriterAppender.setLayout方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testPrintPaths
import org.apache.log4j.WriterAppender; //導入方法依賴的package包/類
@Test
public void testPrintPaths() {
RestOperationMeta staticRes = UnitTestRestUtils.createRestOperationMeta("POST", "/static");
RestOperationMeta dynamicRes = UnitTestRestUtils.createRestOperationMeta("POST", "/dynamic/{id}");
MicroservicePaths paths = new MicroservicePaths();
paths.addResource(staticRes);
paths.addResource(dynamicRes);
WriterAppender appender = new WriterAppender();
Writer writer = new StringWriter();
appender.setWriter(writer);
appender.setLayout(new SimpleLayout());
Logger.getRootLogger().addAppender(appender);
paths.printPaths();
String[] lines = writer.toString().split("\n");
Assert.assertEquals("INFO - Swagger mapped \"{[/static], method=[POST], produces=[application/json]}\" onto null",
lines[0].trim());
Assert.assertEquals(
"INFO - Swagger mapped \"{[/dynamic/{id}], method=[POST], produces=[application/json]}\" onto null",
lines[1].trim());
Logger.getRootLogger().removeAppender(appender);
}
示例2: createLogPanelAppender
import org.apache.log4j.WriterAppender; //導入方法依賴的package包/類
private void createLogPanelAppender() {
WriterAppender appender = new WriterAppender() {
@Override
public void append(LoggingEvent event) {
Platform.runLater(() -> serverLog.appendText(layout.format(event)));
}
};
appender.setName("GuiLogger");
appender.setLayout(new PatternLayout("%d{HH:mm:ss.SSS} - %m%n"));
org.apache.log4j.Logger.getRootLogger().addAppender(appender);
}
示例3: createStringAppender
import org.apache.log4j.WriterAppender; //導入方法依賴的package包/類
private void createStringAppender() {
WriterAppender appender = new WriterAppender();
appender.setName(STRING_APPENDER_NAME);
appender.setLayout(new PatternLayout());
appender.activateOptions();
appender.setWriter(stringWriter);
Logger.getLogger(ImJavaApiLogger.class).addAppender(appender);
}
示例4: createWriterAppender
import org.apache.log4j.WriterAppender; //導入方法依賴的package包/類
public void createWriterAppender() {
PatternLayout layout = new PatternLayout("%m%n");
WriterAppender writerAppender = new WriterAppender();
InputOutput io = IOProvider.getDefault().getIO(Costanti.FLUSSO_SPICY, false);
writerAppender.setWriter(io.getOut());
writerAppender.setName("Output Window Appender");
writerAppender.setLayout(layout);
org.apache.log4j.Logger.getRootLogger().addAppender(writerAppender);
}