当前位置: 首页>>代码示例>>Java>>正文


Java SimpleLayout类代码示例

本文整理汇总了Java中org.apache.log4j.SimpleLayout的典型用法代码示例。如果您正苦于以下问题:Java SimpleLayout类的具体用法?Java SimpleLayout怎么用?Java SimpleLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SimpleLayout类属于org.apache.log4j包,在下文中一共展示了SimpleLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPrintPaths

import org.apache.log4j.SimpleLayout; //导入依赖的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);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:27,代码来源:TestMicroservicePaths.java

示例2: Notifier

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
public Notifier(int port) throws Exception {
    this.port = port;
    Properties properties = new Properties();
    logger.addAppender(new FileAppender(new SimpleLayout(), "notifieroutputlog_" + port
            + ".txt"));

    properties.setProperty("javax.sip.STACK_NAME", "notifier" + port);
    // You need 16 for logging traces. 32 for debug + traces.
    // Your code will limp at 32 but it is best for debugging.
    properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
    properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "notifierdebug_" + port
            + ".txt");
    properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "notifierlog_" + port
            + ".txt");
    if(System.getProperty("enableNIO") != null && System.getProperty("enableNIO").equalsIgnoreCase("true")) {
    	logger.info("\nNIO Enabled\n");
    	properties.setProperty("gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY", NioMessageProcessorFactory.class.getName());
    }
    // Create SipStack object
    sipStack = sipFactory.createSipStack(properties);
    logger.info("sipStack = " + sipStack);
    this.createProvider( );
    this.udpProvider.addSipListener(this);
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:25,代码来源:DeliverNotifyBefore202Test.java

示例3: setLogerConfig

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * 设置日志配置
 * @param level
 * @param fileName
 * @param append
 * @return this
 */
public SpiderApp setLogerConfig(int level,String fileName,boolean append,String configFilename){
	logMap.put("level", level);
	logMap.put("fileName", fileName);
	logMap.put("append",append);
	logMap.put("configFilename",configFilename);
	logger = Logger.getLogger(SpiderApp.class);
	Level logLevel = getLogLevel(level);
	try {
		FileAppender appender = new FileAppender(new SimpleLayout(), fileName,append);
		if(null == configFilename){
			BasicConfigurator.configure();
		}else{
			PropertyConfigurator.configure(configFilename);
		}
		logger.addAppender(appender);
		logger.setLevel(logLevel);
	} catch (IOException e) {
		e.printStackTrace(System.err);
	} 
	return this;
}
 
开发者ID:MashiMaroLjc,项目名称:FunnySpider,代码行数:29,代码来源:SpiderApp.java

示例4: testPrint

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
@Test
public void testPrint() throws Exception {

	DirectedGraph<URI, URI> graph = new DirectedSparseGraph<>();
	graph.addVertex( YURI );
	graph.addVertex( YUGO );
	graph.addEdge( YPY, YURI, YUGO, EdgeType.DIRECTED );

	Collection<URI> roots = Arrays.asList( YURI );
	GraphToTreeConverter.Search search = GraphToTreeConverter.Search.DFS;
	Forest<URI, URI> result = GraphToTreeConverter.convert( graph, roots, search );

	Logger log = Logger.getLogger( GraphToTreeConverter.class );
	StringWriter stringy = new StringWriter();
	WriterAppender app = new WriterAppender( new SimpleLayout(), stringy );
	log.setLevel( Level.DEBUG );
	log.addAppender( app );
	GraphToTreeConverter.printForest( result );
	String output = stringy.toString().replaceAll( "\\s", "" );
	assertEquals( "DEBUG-http://semoss.va.gov/database/T44889381-85ce-43e3-893d-6267fd480660/YuriDEBUG-http://semoss.va.gov/database/T44889381-85ce-43e3-893d-6267fd480660/Yugo", output );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:22,代码来源:GraphToTreeConverterTest.java

示例5: testMissingSprite

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * Tests that the right logger message is executed if the sprite file is
 * invalid.
 */
@Test
public void testMissingSprite() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String inValidSpriteFile = "Sprite asdfsdfSheet";
	SpriteLoader spriteLoader = new SpriteLoader();

	try {
		// The functions to test
		spriteLoader.loadSpriteSheet(inValidSpriteFile, 32, 32);
		spriteLoader.getSprite(1, 0);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You are trying to use a"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
开发者ID:UQdeco2800,项目名称:minesim,代码行数:29,代码来源:SpriteLoaderTests.java

示例6: testNegativeDimensions

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * Tests that the right logger message is executed if an incorrect position
 * (on the sprite sheet) is entered.
 */
@Test
public void testNegativeDimensions() {

	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String validSpriteFile = "peonSheet";
	SpriteLoader spriteLoader = new SpriteLoader();
	try {
		// The functions to test
		spriteLoader.loadSpriteSheet(validSpriteFile, 32, 32);
		spriteLoader.getSprite(-1, -1);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You are requesting a grid position"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
开发者ID:UQdeco2800,项目名称:minesim,代码行数:29,代码来源:SpriteLoaderTests.java

示例7: testPositiveDimensions

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * Tests that the right logger message is executed if an incorrect position
 * (on the sprite sheet) is entered.
 */
@Test
public void testPositiveDimensions() {

	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String validSpriteFile = "peonSheet";
	SpriteLoader spriteLoader = new SpriteLoader();
	try {
		// The functions to test
		spriteLoader.loadSpriteSheet(validSpriteFile, 32, 32);
		spriteLoader.getSprite(6, 6);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You are requesting a grid position"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
开发者ID:UQdeco2800,项目名称:minesim,代码行数:29,代码来源:SpriteLoaderTests.java

示例8: testInvalidSpriteSheetDimensions

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * Tests that the right logger message is executed if an invalid specified
 * sprite dimension is entered.
 */
@Test
public void testInvalidSpriteSheetDimensions() {

	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String validSpriteFile = "peonSheet";
	SpriteLoader spriteLoader = new SpriteLoader();
	try {
		// The functions to test
		spriteLoader.loadSpriteSheet(validSpriteFile, 13, 13);
		spriteLoader.getSprite(1, 0);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("WARN - Your file is not a multiple of"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
开发者ID:UQdeco2800,项目名称:minesim,代码行数:29,代码来源:SpriteLoaderTests.java

示例9: testValidSpriteDimensions

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * Tests that no logger message is executed if valid specified sprite
 * dimensions are entered.
 */
@Test
public void testValidSpriteDimensions() {
	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String validSpriteFile = "peonSheet";
	SpriteLoader spriteLoader = new SpriteLoader();
	try {
		// The functions to test
		spriteLoader.loadSpriteSheet(validSpriteFile, 32, 32);
		spriteLoader.getSprite(1, 0);

		String logMessage = outputStream.toString();
		assertEquals("", logMessage);// should be empty
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
开发者ID:UQdeco2800,项目名称:minesim,代码行数:27,代码来源:SpriteLoaderTests.java

示例10: testNullSpriteSheet

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * Tests that the right logger message is executed if a null sprite sheet
 * file name is entered (i.e. does not exist due to trolling, typos)
 */
@Test
public void testNullSpriteSheet() {
	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Null file name
	String nullSpriteFile = null;
	SpriteLoader spriteLoader = new SpriteLoader();

	try {
		// The function to test
		spriteLoader.loadSpriteSheet(nullSpriteFile, 32, 32);
		assertNull(nullSpriteFile);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - Could not load file"));

	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
开发者ID:UQdeco2800,项目名称:minesim,代码行数:30,代码来源:SpriteLoaderTests.java

示例11: testInvalidSpriteSheet

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * Tests that the right logger message is executed if an invalid sprite
 * sheet file name is entered (i.e. does not exist due to trolling, typos)
 */
@Test
public void testInvalidSpriteSheet() {
	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Invalid file name
	String invalidSpriteFile = "invalid name";
	SpriteLoader spriteLoader = new SpriteLoader();

	try {
		// The function to test
		spriteLoader.loadSpriteSheet(invalidSpriteFile, 32, 32);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - Could not load file"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
开发者ID:UQdeco2800,项目名称:minesim,代码行数:28,代码来源:SpriteLoaderTests.java

示例12: testValidSpriteSheet

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * Tests that no logger message is executed if a valid sprite sheet is
 * entered
 */
@Test
public void testValidSpriteSheet() {
	// Set up logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	// Valid file name
	String validSpriteFile = "peonSheet";
	SpriteLoader spriteLoader = new SpriteLoader();

	try {
		// The function to test
		spriteLoader.loadSpriteSheet(validSpriteFile, 32, 32);
		assertNotNull(validSpriteFile);
		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertEquals("", logMessage);// should be empty
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
开发者ID:UQdeco2800,项目名称:minesim,代码行数:28,代码来源:SpriteLoaderTests.java

示例13: validFrameInitialisation

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * Tests that no logger message is executed for a valid frame setup.
 */
@Test
public void validFrameInitialisation() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);

	try {
		// The functions to test
		frame = new Frame(mockSprite, 10);
		assertNotNull(frame.getFrame());
		assertTrue(frame.getDuration() == 10);

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertEquals("", logMessage);
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
开发者ID:UQdeco2800,项目名称:minesim,代码行数:27,代码来源:FrameTests.java

示例14: validGetters

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * Tests that getters are not null if there is a valid Frame initilisation.
 */
@Test
public void validGetters() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	Image mockSprite = mock(Image.class);

	try {
		// The functions to test
		frame = new Frame(mockSprite, 10);
		assertNotNull(frame.getFrame());
		assertNotNull(frame.getDuration());

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertEquals("", logMessage);
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
开发者ID:UQdeco2800,项目名称:minesim,代码行数:27,代码来源:FrameTests.java

示例15: inValidFrame

import org.apache.log4j.SimpleLayout; //导入依赖的package包/类
/**
 * Tests that the appropriate error message is displayed if the frame image
 * is null.
 */
@Test
public void inValidFrame() {
	// Set up of logger retrieval
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	Layout layout = new SimpleLayout();
	Appender appender = new WriterAppender(layout, outputStream);
	LOGGER.addAppender(appender);

	try {
		// The functions to test
		frame = new Frame(null, 10);
		assertNull(frame.getFrame());

		String logMessage = outputStream.toString();
		assertNotNull(logMessage);
		assertTrue(logMessage.contains("ERROR - You cannot have null frames"));
	} finally {
		LOGGER.removeAppender(appender);
	}
}
 
开发者ID:UQdeco2800,项目名称:minesim,代码行数:25,代码来源:FrameTests.java


注:本文中的org.apache.log4j.SimpleLayout类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。