本文整理汇总了Java中org.apache.log4j.WriterAppender.setWriter方法的典型用法代码示例。如果您正苦于以下问题:Java WriterAppender.setWriter方法的具体用法?Java WriterAppender.setWriter怎么用?Java WriterAppender.setWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.WriterAppender
的用法示例。
在下文中一共展示了WriterAppender.setWriter方法的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: initialize
import org.apache.log4j.WriterAppender; //导入方法依赖的package包/类
private void initialize(String propsName)
throws Exception
{
URL config = ClassLoader.getSystemResource(propsName);
PropertyConfigurator.configure(config);
logger = Logger.getLogger(getClass());
Logger rootLogger = Logger.getRootLogger();
appender = (WriterAppender)rootLogger.getAppender("default");
writer = new StringWriter();
appender.setWriter(writer);
}
示例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);
}