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


Java FileAppender.setAppend方法代碼示例

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


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

示例1: setupLogging

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
private void setupLogging() {
    LogManager.getLogManager().reset();
    Logger.getRootLogger().getLoggerRepository().resetConfiguration();

    final Logger rootLogger = Logger.getRootLogger();
    final PatternLayout layout = new PatternLayout("%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n");
    final Level level = endPointHealthConfiguration.logLevel();

    final ConsoleAppender consoleAppender = new ConsoleAppender(layout, ConsoleAppender.SYSTEM_ERR);

    consoleAppender.setThreshold(level);
    consoleAppender.activateOptions();

    final FileAppender fileAppender = new FileAppender();

    fileAppender.setFile(endPointHealthConfiguration.logFile().getAbsolutePath());
    fileAppender.setLayout(layout);
    fileAppender.setThreshold(level);
    fileAppender.setAppend(true);
    fileAppender.setErrorHandler(new FallbackAppenderErrorHandler(rootLogger, fileAppender, consoleAppender));

    rootLogger.addAppender(fileAppender);

    fileAppender.activateOptions();
}
 
開發者ID:spypunk,項目名稱:endpoint-health,代碼行數:26,代碼來源:EndPointHealthServiceImpl.java

示例2: addAppender

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
public static void addAppender() {
	FileAppender fa = new FileAppender();
	fa.setName("FileLogger");
	String logFile = getConfHome() + System.getProperty("file.separator") + "zoofx.log";
	fa.setFile(logFile);
	
	Enumeration<Appender> allAppenders = Logger.getRootLogger().getAllAppenders();
	if(allAppenders.hasMoreElements()){
		Appender appender = allAppenders.nextElement();
		if(appender instanceof ConsoleAppender){
			ConsoleAppender ca = (ConsoleAppender)appender;
			fa.setLayout(ca.getLayout());
			fa.setThreshold(ca.getThreshold());
		}
		fa.setAppend(true);
	}
	fa.activateOptions();
	
	Logger.getRootLogger().addAppender(fa);
}
 
開發者ID:ajiniesta,項目名稱:zoofx,代碼行數:21,代碼來源:ZFXConf.java

示例3: setUp

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
	try {
		Files.delete(Paths.get(FILEPATH));
	} catch (Exception e) {
		// TODO: handle exception
	}
	
	FileAppender fa = new FileAppender();
	fa.setName("FileLogger");
	fa.setFile(FILEPATH);
	fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
	fa.setThreshold(Level.DEBUG);
	fa.setAppend(true);
	fa.activateOptions();

	//add appender to any Logger (here is root)
	Logger.getRootLogger().addAppender(fa);
}
 
開發者ID:bkusche,項目名稱:bktail2,代碼行數:20,代碼來源:LogfileHandlerTest.java

示例4: getLogger

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
public Logger getLogger(Logger logger, JEVisObject dataSource) {
    String loggerFileName = dataSource.getName().replace(" ", "_") + "_ID(" + dataSource.getID() + ").log";
    String loggerName = dataSource.getID().toString();
    MDC.put(KEY, "" + loggerName);

    FileAppender appender = new FileAppender();
    appender.setLayout(new PatternLayout("[%d{dd MMM yyyy HH:mm:ss}][%c{2}]: %-10m%n"));
    appender.setFile(loggerFileName);
    appender.setAppend(true);
    appender.setImmediateFlush(true);
    appender.activateOptions();
    appender.setName(loggerName);
    ThreadFilter threadFilter = new ThreadFilter(loggerName);
    appender.addFilter(threadFilter);
    logger.setAdditivity(false);    //<--do not use default root logger
    logger.addAppender(appender);
    return logger;
}
 
開發者ID:OpenJEVis,項目名稱:JECommons,代碼行數:19,代碼來源:DriverLoggerFactory.java

示例5: init

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
private static void init() {
    ConsoleAppender console = new ConsoleAppender(); //create appender
    //configure the appender
    String PATTERN = "%d [%p|%c|%C{1}] %m%n";
    console.setLayout(new PatternLayout(PATTERN));
    console.setThreshold(Level.TRACE);
    console.activateOptions();
    //add appender to any Logger (here is root)
    Logger.getRootLogger().addAppender(console);

    FileAppender fa = new FileAppender();
    fa.setName("FileLogger");
    fa.setFile("log.log");
    fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
    fa.setThreshold(Level.TRACE);
    fa.setAppend(true);
    fa.activateOptions();

    //add appender to any Logger (here is root)
    Logger.getRootLogger().addAppender(fa);

}
 
開發者ID:miho,項目名稱:PiOnWheels,代碼行數:23,代碼來源:Main.java

示例6: initializeAnalysisLog

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
/**
 * Initialize the log4j logging infrastructure for the analysis run.
 */
private void initializeAnalysisLog() {

    // build the path of the log file
    // inside a log directory of the analysis workflow
    DateFormat logDateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
    String logFile = WorkspaceUtil.getAbsoluteFromProjectRelativePath(
            "logs/vpm-analysis-" + (logDateFormat.format(new Date())) + ".csv",
            config.getSplevoProjectEditor().getSplevoProject());
    
    FileAppender fa = new FileAppender();
    fa.setName(CloseAnalysisTraceLogAppenderJob.LOG_APPENDER_NAME);
    fa.setFile(logFile);
    fa.setLayout(new PatternLayout("%m%n"));
    fa.setThreshold(Level.DEBUG);
    fa.setAppend(false);
    fa.activateOptions();
    Logger.getLogger(VPMAnalyzer.LOG_CATEGORY).removeAllAppenders();
    Logger.getLogger(VPMAnalyzer.LOG_CATEGORY).addAppender(fa);

    // insert header row
    Logger.getLogger(VPMAnalyzer.LOG_CATEGORY).info("Analyzer,VP1, VP2, SourceInfo, TargetInfo, Remark");

}
 
開發者ID:kopl,項目名稱:SPLevo,代碼行數:27,代碼來源:VPMAnalysisWorkflowDelegate.java

示例7: setupLogging

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
private void setupLogging() {
	// add in our custom per-file logging appender. anything that happens for this particular
	// file should go in this log file
	FileAppender appender = new FileAppender();

	File file = fileService.getById(getServiceContext(), getFileId());

	appender.setName("batch-" + getFileId());
	appender.setLayout(new PatternLayout("%d %-5p %c %x - %m%n"));
	appender.setFile(file.getPath() + java.io.File.separator + file.getFilename() + ".log");
	appender.setAppend(true);
	appender.activateOptions();

	Logger logger = Logger.getRootLogger();
	logger.addAppender(appender);
}
 
開發者ID:SmarterApp,項目名稱:TechnologyReadinessTool,代碼行數:17,代碼來源:JobCompletionListener.java

示例8: addFileAppender

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
private void addFileAppender(Logger rootLogger) {
	FileAppender fa = new FileAppender();
	  fa.setName("FileLogger");
	  fa.setFile("rubus.log");
	  fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
	  fa.setThreshold(Level.DEBUG);
	  fa.setAppend(true);
	  fa.activateOptions();

	  //add appender to any Logger (here is root)
	  Logger.getRootLogger().addAppender(fa);
	
}
 
開發者ID:adnanmitf09,項目名稱:Rubus,代碼行數:14,代碼來源:Rubus.java

示例9: SetFileLogger

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
public static void SetFileLogger(Level level, String filename) {
    FileAppender fa = new FileAppender();
    fa.setName("FileLogger_Debug");
    fa.setFile(filename);
    fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
    fa.setThreshold(level);
    fa.setAppend(false);
    fa.activateOptions();
    Logger.getRootLogger().addAppender(fa);
}
 
開發者ID:YcheCourseProject,項目名稱:DIA-Umpire-Maven,代碼行數:11,代碼來源:ConsoleLogger.java

示例10: CISCoreStandaloneApp

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
public CISCoreStandaloneApp() throws CISConfigException {
	ConsoleAppender console = new ConsoleAppender(); //create appender
	  //configure the appender
	  String PATTERN = "%d [%p|%c|%C{1}] %m%n";
	  console.setLayout(new PatternLayout(PATTERN)); 
	  console.setThreshold(Level.DEBUG);
	  console.activateOptions();
	  //add appender to any Logger (here is root)
	  Logger.getRootLogger().addAppender(console);

	  FileAppender fa = new FileAppender();
	  fa.setName("CISCoreLogger");
	  fa.setFile("./log/CISCore.log");
	  fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
	  fa.setThreshold(Level.DEBUG);
	  fa.setAppend(true);
	  fa.activateOptions();

	  //add appender to any Logger (here is root)
	  Logger.getRootLogger().addAppender((Appender)fa);
	  //repeat with all other desired appenders
	  
	  log = Logger.getLogger(this.getClass());
	  
	  Boolean ignoreError = Boolean.parseBoolean(PropertiesReader.getInstance().getPropertie("startup.ignore.error"));
	  log.info("Ignore Errors on CoreStartup: " + ignoreError);
	  
	  try {
		  CISCoreImpl cisCore = CISCoreImpl.getInstance();
	  } catch (Exception e) {
		  if (!ignoreError) {
			  throw e;
		  }
	  }
	  
	  ConnectorCallbackHandlerImpl callbackHandler = ConnectorCallbackHandlerImpl.getInstance();
	  callbackHandler.registerCallback(new RestConnectorCallback(PropertiesReader.getInstance().getPropertie("core.connector.rest.callback")));
	  
	  log.info("Init. CISCoreStandaloneApp");
}
 
開發者ID:DRIVER-EU,項目名稱:CommonInformationSpace,代碼行數:41,代碼來源:CISCoreStandaloneApp.java

示例11: addLog4jFileAppender

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
Path addLog4jFileAppender(final Path path) throws IOException {
    org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger();

    String pattern = "%d{HH:mm:ss.SSS} %-5p %t %C{1}.%M:%L - %m%n";
    final String threadName = Thread.currentThread().getName();

    class ThreadFilter extends Filter {
        @Override
        public int decide(LoggingEvent event) {
            if (event.getThreadName().startsWith(threadName)) {
                return Filter.ACCEPT;
            }
            return Filter.DENY;
        }
    }

    FileAppender fa = new FileAppender(new PatternLayout(pattern), path.toFile().getAbsolutePath());
    fa.addFilter(new ThreadFilter());
    fa.setThreshold(sysConfig.getCaseLogLevel());
    fa.setImmediateFlush(true);
    fa.setAppend(true);
    fa.setName(path.toFile().getAbsolutePath());

    fa.activateOptions();
    rootLogger.addAppender(fa);

    return path;
}
 
開發者ID:tascape,項目名稱:reactor,代碼行數:29,代碼來源:AbstractCaseRunner.java

示例12: initLogger

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
private static void initLogger(String filename) {
	final String PATTERN = "[%d{yyyy-MM-dd HH:mm:ss}] [%-5p] [%c{1}] %m%n";
	
	// Stores whether an error has occured
	AppenderSkeleton errorFlagAppender = new ErrorFlagAppender();
	errorFlagAppender.setThreshold(Level.ERROR);
	errorFlagAppender.activateOptions();
	org.apache.log4j.Logger.getRootLogger().addAppender(errorFlagAppender);

	ConsoleAppender consoleAppender = new ConsoleAppender(); 
	consoleAppender.setEncoding("UTF-8");
	consoleAppender.setLayout(new PatternLayout(PATTERN)); 
	consoleAppender.setThreshold(LOG_LEVEL);
	consoleAppender.activateOptions();		
	AsyncAppender asyncConsoleAppender = new AsyncAppender();
	asyncConsoleAppender.addAppender(consoleAppender);
	asyncConsoleAppender.setBufferSize(1024);
	asyncConsoleAppender.activateOptions();
	org.apache.log4j.Logger.getRootLogger().addAppender(asyncConsoleAppender);
	
	FileAppender fileAppender = new FileAppender();
	fileAppender.setEncoding("UTF-8");
	fileAppender.setFile(filename);
	fileAppender.setLayout(new PatternLayout(PATTERN));
	fileAppender.setThreshold(LOG_LEVEL);
	fileAppender.setAppend(false);
	fileAppender.activateOptions();
	AsyncAppender asyncFileAppender = new AsyncAppender();
	asyncFileAppender.addAppender(fileAppender);
	asyncFileAppender.setBufferSize(1024);
	asyncFileAppender.activateOptions();
	org.apache.log4j.Logger.getRootLogger().addAppender(asyncFileAppender);
	
}
 
開發者ID:heindorf,項目名稱:cikm16-wdvd-feature-extraction,代碼行數:35,代碼來源:FeatureExtractor.java

示例13: configureLogger

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
public static void configureLogger(File logFile) {
    Bundle bundle = Platform.getBundle("tools.vitruv.integration");
    URL fileURL = bundle.getEntry("log4j.xml");
    DOMConfigurator.configure(fileURL);

    FileAppender appender = new FileAppender();
    appender.setName("LogFile");
    appender.setFile(logFile.getAbsolutePath());
    appender.setThreshold(Level.INFO);
    appender.setLayout(new PatternLayout("%-5p [%t]: %m%n"));
    appender.setAppend(true);
    appender.activateOptions();

    Logger.getRootLogger().addAppender(appender);
}
 
開發者ID:vitruv-tools,項目名稱:Vitruv,代碼行數:16,代碼來源:LoggerConfigurator.java

示例14: initLogger

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
public static void initLogger() {
  if (logger == null) {
    long requiredFreeSpace = 1000000;
    String logFolder = getDir(requiredFreeSpace);
    FileAppender update = new FileAppender();

    update.setFile(new File(logFolder, "idea_updater.log").getAbsolutePath());
    update.setLayout(new PatternLayout("%d{dd MMM yyyy HH:mm:ss} %-5p %C{1}.%M - %m%n"));
    update.setThreshold(Level.ALL);
    update.setAppend(true);
    update.activateOptions();

    FileAppender updateError = new FileAppender();
    updateError.setFile(new File(logFolder, "idea_updater_error.log").getAbsolutePath());
    updateError.setLayout(new PatternLayout("%d{dd MMM yyyy HH:mm:ss} %-5p %C{1}.%M - %m%n"));
    updateError.setThreshold(Level.ERROR);
    updateError.setAppend(false);
    updateError.activateOptions();

    logger = Logger.getLogger("com.intellij.updater");
    logger.addAppender(updateError);
    logger.addAppender(update);
    logger.setLevel(Level.ALL);

    logger.info("--- Updater started ---");
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:Runner.java

示例15: initLog4j

import org.apache.log4j.FileAppender; //導入方法依賴的package包/類
private void initLog4j() {
	FileAppender fa = new FileAppender();
	fa.setName(LOG4J_FILE_APPENDER_NAME);
	fa.setFile(getLogPath());
	fa.setLayout(new PatternLayout("%d{dd.MM.yyyy HH:mm:ss,SS} %-5p %C{1} - %m%n"));
	fa.setThreshold(Level.DEBUG);
	fa.setAppend(true);
	fa.activateOptions();

	Logger.getRootLogger().addAppender(fa);
}
 
開發者ID:mnikliborc,項目名稱:clicktrace,代碼行數:12,代碼來源:AppProperties.java


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