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


Java RollingFileAppender.setImmediateFlush方法代碼示例

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


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

示例1: initLogger

import org.apache.log4j.RollingFileAppender; //導入方法依賴的package包/類
private static void initLogger() {
	Logger rootLogger = Logger.getRootLogger();
	PatternLayout layout = new PatternLayout("%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n");

	try {
		RollingFileAppender fileAppender = new RollingFileAppender(layout, System.getProperty("log.file", "./vnt.log"));
		fileAppender.setImmediateFlush(true);
		fileAppender.setThreshold(Level.DEBUG);
		fileAppender.setAppend(true);
		fileAppender.setMaxFileSize("5MB");
		fileAppender.setMaxBackupIndex(2);

		rootLogger.addAppender(fileAppender);
	} catch (IOException e) {
		log.error("Failed to add appender !!", e);
	}
}
 
開發者ID:crsmoro,項目名稱:vntscraper,代碼行數:18,代碼來源:VntMain.java

示例2: initLogger

import org.apache.log4j.RollingFileAppender; //導入方法依賴的package包/類
private static void initLogger() {
	// This is the root logger provided by log4j
	Logger rootLogger = Logger.getRootLogger();

	// Define log pattern layout
	PatternLayout layout = new PatternLayout("%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n");

	try {
		// Define file appender with layout and output log file name
		RollingFileAppender fileAppender = new RollingFileAppender(layout, "./scplayer.log");
		fileAppender.setImmediateFlush(true);
		fileAppender.setThreshold(Level.DEBUG);
		fileAppender.setAppend(true);
		fileAppender.setMaxFileSize("5MB");
		fileAppender.setMaxBackupIndex(2);

		// Add the appender to root logger
		rootLogger.addAppender(fileAppender);
	} catch (IOException e) {
		System.out.println("Failed to add appender !!");
		System.exit(-1);
	}
}
 
開發者ID:crsmoro,項目名稱:scplayer,代碼行數:24,代碼來源:SCPlayerMain.java

示例3: testImmediateFlushOff

import org.apache.log4j.RollingFileAppender; //導入方法依賴的package包/類
@Test
public void testImmediateFlushOff()
{
  RollingFileAppender rfa = (RollingFileAppender)logger.getAppender(APPENDER_NAME);
  assertTrue(rfa.getImmediateFlush());
  rfa.setImmediateFlush(false);
  assertNull(LoggerUtil.getLogFileInformation());
  rfa.setImmediateFlush(true);
}
 
開發者ID:apache,項目名稱:apex-core,代碼行數:10,代碼來源:LogFileInformationTest.java

示例4: configureLog4J

import org.apache.log4j.RollingFileAppender; //導入方法依賴的package包/類
/**
 * Configures the Log4J properties
 * 
 * @param logFilePath
 *            The log file path
 */
private void configureLog4J(String logFilePath) {

	// This is the root logger provided by log4j
	Logger rootLogger = Logger.getRootLogger();
	rootLogger.setLevel(Level.DEBUG);

	// Define log pattern layout
	PatternLayout layout = new PatternLayout("[%-5p] %d %c - %m%n");

	// Add console appender to root logger
	if (rootLogger.getAppender(LOG_CONSOLE_APPENDER_NAME) == null) {
		ConsoleAppender consoleAppender = new ConsoleAppender(layout);
		consoleAppender.setName(LOG_CONSOLE_APPENDER_NAME);
		rootLogger.addAppender(consoleAppender);
	}

	// Add file appender with layout and output log file name
	try {
		if (rootLogger.getAppender(LOG_FILE_APPENDER_NAME) == null) {
			RollingFileAppender fileAppender = new RollingFileAppender(
					layout, logFilePath);
			fileAppender.setAppend(false);
			fileAppender.setImmediateFlush(true);
			fileAppender.setName(LOG_FILE_APPENDER_NAME);
			fileAppender.setMaxFileSize("5MB");
			fileAppender.setMaxBackupIndex(10);
			rootLogger.addAppender(fileAppender);
		}
	} catch (IOException e) {
		System.out.println("Failed to add appender !!");
	}
}
 
開發者ID:aguelle,項目名稱:MIDI-Automator,代碼行數:39,代碼來源:Resources.java


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