當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。