當前位置: 首頁>>代碼示例>>Java>>正文


Java StreamHandler.close方法代碼示例

本文整理匯總了Java中java.util.logging.StreamHandler.close方法的典型用法代碼示例。如果您正苦於以下問題:Java StreamHandler.close方法的具體用法?Java StreamHandler.close怎麽用?Java StreamHandler.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.logging.StreamHandler的用法示例。


在下文中一共展示了StreamHandler.close方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testLogger

import java.util.logging.StreamHandler; //導入方法依賴的package包/類
private void testLogger( StreamHandler afh ) {
    Handler[] handlers = LOGGER.getHandlers();
    for ( Handler handler : handlers ) {
        try {
            LOGGER.removeHandler( handler );
        } catch ( Exception e ) {
            e.printStackTrace();
        }
    }
    afh.setFormatter( new SimpleFormatter() );
    afh.setLevel( Level.FINEST );
    LOGGER.addHandler( afh );
    LOGGER.setLevel( Level.FINEST );

    final int threadCount = 20;
    final int logEntryCount = 100000;

    generateLogs( threadCount, logEntryCount );

    afh.close();

}
 
開發者ID:dd00f,項目名稱:ibm-performance-monitor,代碼行數:23,代碼來源:AsynchronousLoggerTest.java

示例2: testPublish_AfterClose

import java.util.logging.StreamHandler; //導入方法依賴的package包/類
public void testPublish_AfterClose() throws Exception {
	Properties p = new Properties();
	p.put("java.util.logging.StreamHandler.level", "FINE");
	LogManager.getLogManager().readConfiguration(
			EnvironmentHelper.PropertiesToInputStream(p));

	ByteArrayOutputStream aos = new ByteArrayOutputStream();
	StreamHandler h = new StreamHandler(aos, new MockFormatter());
	assertSame(h.getLevel(), Level.FINE);
	LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFormatter");
	assertTrue(h.isLoggable(r));
	h.close();
	assertFalse(h.isLoggable(r));
	h.publish(r);
	h.flush();
	assertEquals("MockFormatter_HeadMockFormatter_Tail", aos.toString());
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:18,代碼來源:StreamHandlerTest.java

示例3: testClose_SufficientPrivilege_NormalClose

import java.util.logging.StreamHandler; //導入方法依賴的package包/類
public void testClose_SufficientPrivilege_NormalClose() {
	ByteArrayOutputStream aos = new MockOutputStream();
	StreamHandler h = new StreamHandler(aos, new MockFormatter());
	h.publish(new LogRecord(Level.SEVERE,
			"testClose_SufficientPrivilege_NormalClose msg"));
	h.close();
	assertEquals("close", CallVerificationStack.getInstance()
			.getCurrentSourceMethod());
	assertNull(CallVerificationStack.getInstance().pop());
	assertEquals("flush", CallVerificationStack.getInstance()
			.getCurrentSourceMethod());
	CallVerificationStack.getInstance().clear();
	assertTrue(aos.toString().endsWith("MockFormatter_Tail"));
	h.close();
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:16,代碼來源:StreamHandlerTest.java

示例4: testClose_SufficientPrivilege_Exception

import java.util.logging.StreamHandler; //導入方法依賴的package包/類
public void testClose_SufficientPrivilege_Exception() {
	ByteArrayOutputStream aos = new MockExceptionOutputStream();
	StreamHandler h = new StreamHandler(aos, new MockFormatter());
	h.publish(new LogRecord(Level.SEVERE,
			"testClose_SufficientPrivilege_Exception msg"));
	h.flush();
	h.close();
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:9,代碼來源:StreamHandlerTest.java

示例5: testClose_SufficientPrivilege_DirectClose

import java.util.logging.StreamHandler; //導入方法依賴的package包/類
public void testClose_SufficientPrivilege_DirectClose() {
	ByteArrayOutputStream aos = new MockOutputStream();
	StreamHandler h = new StreamHandler(aos, new MockFormatter());
	h.close();
	assertEquals("close", CallVerificationStack.getInstance()
			.getCurrentSourceMethod());
	assertNull(CallVerificationStack.getInstance().pop());
	assertEquals("flush", CallVerificationStack.getInstance()
			.getCurrentSourceMethod());
	CallVerificationStack.getInstance().clear();
	assertEquals("MockFormatter_HeadMockFormatter_Tail", aos.toString()
			);
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:14,代碼來源:StreamHandlerTest.java

示例6: testClose_InsufficientPrivilege

import java.util.logging.StreamHandler; //導入方法依賴的package包/類
public void testClose_InsufficientPrivilege() {
	SecurityManager oldMan = System.getSecurityManager();
	System.setSecurityManager(new MockSecurityManager());
	try {
		StreamHandler h = new StreamHandler(new ByteArrayOutputStream(),
				new MockFormatter());
		h.close();
		fail("Should throw SecurityException!");
	} catch (SecurityException e) {
		// expected
	} finally {
		System.setSecurityManager(oldMan);
	}
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:15,代碼來源:StreamHandlerTest.java

示例7: testClose_NoOutputStream

import java.util.logging.StreamHandler; //導入方法依賴的package包/類
public void testClose_NoOutputStream() {
	StreamHandler h = new StreamHandler();
	h.close();
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:5,代碼來源:StreamHandlerTest.java


注:本文中的java.util.logging.StreamHandler.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。