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


Java FileHandler.setLevel方法代码示例

本文整理汇总了Java中java.util.logging.FileHandler.setLevel方法的典型用法代码示例。如果您正苦于以下问题:Java FileHandler.setLevel方法的具体用法?Java FileHandler.setLevel怎么用?Java FileHandler.setLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.logging.FileHandler的用法示例。


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

示例1: Server

import java.util.logging.FileHandler; //导入方法依赖的package包/类
public Server(String fileName, boolean restart) {
	super();
	parseServerFile(fileName);
	seatAssignments = new ArrayList<>(nSeats);
	for (int i = 0; i < nSeats; i++)
		seatAssignments.add("");

	log.getParent().removeHandler(log.getParent().getHandlers()[0]);
	
	try {
		// check if logs dir exists
		File logDir = new File("./logs/"); 
		if( !(logDir.exists()) )
			logDir.mkdir();
			
		FileHandler fh = new FileHandler("logs/server_log_" + serverID + ".log");
		fh.setFormatter(new SimpleFormatter());
		fh.setLevel(logLevel);
		log.addHandler(fh);
		
		ConsoleHandler ch = new ConsoleHandler();
		ch.setLevel(logLevel);
		log.addHandler(ch);
		log.setLevel(logLevel);
		
		log.info("Server initializing...");
		log.info("ServerID = " + serverID);
		log.info("nServers = " + nServers);
		log.info("nSeats = " + nSeats);
		log.info("my tcp port = " + tcpPort);
		for (int i = 0; i < nServers; i++)
			log.info("Server " + i + ": " + servers.get(i) + ":" + ports.get(i));
		log.info("Server init complete");
		log.info("--------------------------------");
		mutex = new LamportMutex(servers, ports, this, restart);
		mutex.init();
	} catch (SecurityException | IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:ericaddison,项目名称:Dist_HW_2,代码行数:41,代码来源:Server.java

示例2: AptaLogger

import java.util.logging.FileHandler; //导入方法依赖的package包/类
private AptaLogger() throws IOException{
  
    //instance the file handler
    filepath = Paths.get(Configuration.getParameters().getString("Experiment.projectPath"), "log_" + formatter.format(new Date()) + ".txt").toString();
    fileHandler = new FileHandler(filepath,true);
    fileHandler.setLevel(Level.ALL); // We want everything logged on file
    
	//instance the logger
    logger = Logger.getLogger(AptaLogger.class.getName());  
    logger.setUseParentHandlers(false);
    logger.setLevel(Level.ALL);
    
    //instance formatter, set formatting, and handler
    formatterTxt = new AptaLoggerFormat();
    fileHandler.setFormatter(formatterTxt);
    
    logger.addHandler(fileHandler);

}
 
开发者ID:drivenbyentropy,项目名称:aptasuite,代码行数:20,代码来源:AptaLogger.java

示例3: LogService

import java.util.logging.FileHandler; //导入方法依赖的package包/类
private LogService(Logger logger) {
	super(logger);

	// setup a log file if the execution mode can access the filesystem (e.g. not for RA)
	// we want our logfile to look the same regardless of any user settings, so ignore
	// a possible user logging property config file
	if (RapidMiner.getExecutionMode().canAccessFilesystem()) {
		try {
			FileHandler logFileHandler = new FileHandler(FileSystemService.getLogFile().getAbsolutePath(), false);
			logFileHandler.setLevel(Level.ALL);
			logFileHandler.setFormatter(new SimpleFormatter());
			LogService.getRoot().addHandler(logFileHandler);
		} catch (IOException e) {
			LogService.getRoot().log(Level.WARNING, "com.rapidminer.logservice.logfile.failed_to_init", e.getMessage());
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:18,代码来源:LogService.java

示例4: initGlobals

import java.util.logging.FileHandler; //导入方法依赖的package包/类
/**
 * Initializes all globals to a default state. Used so that in the case of a
 * memory leak, the previous values are not accidentally used.
 */
public static void initGlobals() {
    System.setProperty("java.util.logging.SimpleFormatter.format", 
        "(%1$tc) [%4$s] ~%2$s~%nMessage: \"%5$s\"%n");
    try {
        handler = new FileHandler("log.txt");
        handler.setLevel(Level.INFO);
        handler.setFormatter(new SimpleFormatter());
        
        // Ensure we only log to log file.
        LOGGER.setUseParentHandlers(false);
        LOGGER.addHandler(handler);
        
        LOGGER.setLevel(Level.INFO);
    } catch (IOException | SecurityException ex) {
        throw new RuntimeException("Failed to initialized logger... " + ex.getMessage());
    }
    PROJECT_FOLDER = null;
    URI_PREFIX = null;
    CURRENT_FILE = null;
}
 
开发者ID:LouisJenkinsCS,项目名称:Code-Glosser,代码行数:25,代码来源:Globals.java

示例5: configureLogger

import java.util.logging.FileHandler; //导入方法依赖的package包/类
protected void configureLogger() throws SecurityException, IOException {
  if (logger == null) {
    logger = Logger.getLogger(LOGGER_NAME);
  }
  logger.setUseParentHandlers(false);
  logFileHandler = new FileHandler(logFilePath);
  logFileHandler.setFormatter(new SimpleFormatter());
  Level logLevel = Level.INFO;
  try {
    logLevel = Level.parse(logLevelString);
  } catch (IllegalArgumentException e) {
    logInfo("Unrecognized log level :" + logLevelString + " defaulting to :" + logLevel);
  }
  logFileHandler.setLevel(logLevel);
  logger.addHandler(logFileHandler);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:17,代码来源:GemFireXDDataExtractorImpl.java

示例6: main

import java.util.logging.FileHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws SecurityException, IOException {
	Logger logger = Logger.getGlobal();
	logger.setLevel(Level.FINER);
	System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tF %1$tT %4$s %2$s %5$s%6$s%n");

	SimpleFormatter formatterTxt = new SimpleFormatter();
	FileHandler logFile = new FileHandler("log2.txt");
	logFile.setLevel(Level.FINER);

	logFile.setFormatter(formatterTxt);
	logger.addHandler(logFile);

	// Create and set handler
	Handler systemOut = new StdoutConsoleHandler();
	systemOut.setLevel(Level.ALL);

	logger.addHandler(systemOut);
	logger.setLevel(Level.SEVERE);

	// Prevent logs from processed by default Console handler.
	logger.setUseParentHandlers(false); // Solution 1

	new MiniBrassCompiler().doMain(args);
}
 
开发者ID:isse-augsburg,项目名称:minibrass,代码行数:25,代码来源:MiniBrassCompiler.java

示例7: main

import java.util.logging.FileHandler; //导入方法依赖的package包/类
/**
 * Main entry point for the OpenOffice.org Bean Test.
 *
 * @param args arguments of the test
 *
 * @author Andreas Bröker
 * @date 21.05.2006
 */
public static void main(String[] args) throws OfficeApplicationException {

   LogManager.getLogManager().reset();
   ConsoleHandler consoleHandler = new ConsoleHandler();
   consoleHandler.setLevel(Level.FINEST);
   LOGGER.addHandler(consoleHandler);
   LOGGER.setLevel(Level.FINEST);

   try {
      FileHandler fileHandler = new FileHandler("log.xml");
      fileHandler.setLevel(Level.FINEST);
      LOGGER.addHandler(fileHandler);
   } catch (Throwable throwable) {
   }
   OfficeBeanTest testOfficeBean = new OfficeBeanTest();

   if (args.length == 0) {
      testOfficeBean.test(null);
   }else if (args.length == 1) {
      testOfficeBean.test(args[0]);
   }else if(args.length==4){
      testOfficeBean.remoteTestPDF(new File(args[2]), new File(args[3]), args[0], Integer.valueOf(args[1]));
   }else{
      System.out.println("usage:\nOfficeBeanTest host port source-odt target-pdf\nOfficeBeanTest officeHome");
   }
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:35,代码来源:OfficeBeanTest.java

示例8: addNewSeleniumFileHandler

import java.util.logging.FileHandler; //导入方法依赖的package包/类
private static File addNewSeleniumFileHandler(Logger currentLogger,
    LoggingOptions options) {
  try {
    FileHandler fileHandler;
    final File logFile;

    logFile = options.getLogOutFile();
    fileHandler = seleniumFileHandlers.get(logFile);
    if (fileHandler == null) {
      fileHandler = registerNewSeleniumFileHandler(logFile);
    }
    fileHandler.setFormatter(new TerseFormatter(true));
    currentLogger.setLevel(Level.FINE);
    fileHandler.setLevel(Level.FINE);
    currentLogger.addHandler(fileHandler);
    return logFile;
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:21,代码来源:LoggingManager.java

示例9: setupLogging

import java.util.logging.FileHandler; //导入方法依赖的package包/类
private void setupLogging() {
    log.setUseParentHandlers(false);

    LogFormatter formatter = new LogFormatter();

    ConsoleHandler ch = new ConsoleHandler();
    ch.setFormatter(formatter);
    if (isDebugging()) {
        log.setLevel(Level.FINEST);
        ch.setLevel(Level.FINEST);
    } else {
        log.setLevel(Level.INFO);
        ch.setLevel(Level.INFO);
    }
    log.addHandler(ch);

    try {
        FileHandler fh = new FileHandler("server.log");
        fh.setFormatter(formatter);
        if (isDebugging()) {
            fh.setLevel(Level.FINEST);
        } else {
            ch.setLevel(Level.INFO);
        }
        log.addHandler(fh);
    } catch (IOException ex) {
        log.log(Level.SEVERE, "Error while adding FileHandler to logger. Logs will not be output to a file.", ex);
    }

}
 
开发者ID:OgarProject,项目名称:Ogar2-Server,代码行数:31,代码来源:OgarServer.java

示例10: setupLogging

import java.util.logging.FileHandler; //导入方法依赖的package包/类
public static void setupLogging(boolean logToConsole, String logFile) throws Exception {
   // Setup the logging
   System.setProperty(
            "java.util.logging.SimpleFormatter.format",
            "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS: %4$s: %5$s%n%6$s%n");
   LogManager.getLogManager().reset();
   Logger rootLogger = Logger.getLogger("");
   if(logFile != null) {
      FileHandler logHandler = new FileHandler(logFile, 8*1024*1024, 2, true);
      logHandler.setFormatter(new SimpleFormatter()); 
      logHandler.setLevel(Level.FINEST); 
      rootLogger.addHandler(logHandler);
   }
   
   if(logToConsole) {
      ConsoleHandler consoleHandler = new ConsoleHandler();
      consoleHandler.setFormatter(new SimpleFormatter());
      consoleHandler.setLevel(Level.INFO);
      rootLogger.addHandler(consoleHandler);
   }
    
   rootLogger.setLevel(Level.INFO);
}
 
开发者ID:ivannp,项目名称:tradelib,代码行数:24,代码来源:Utils.java

示例11: initLog

import java.util.logging.FileHandler; //导入方法依赖的package包/类
private static void initLog()
{
	Formatter simpleFormatter;

	try
	{
		String path = new File(".").getCanonicalPath();
		String logName = String.valueOf(System.currentTimeMillis());
		simpleFormatter = new SimpleFormatter();
		fileHandler = new FileHandler(path + logName + ".log");
		fileHandler.setFormatter(simpleFormatter);
		fileHandler.setLevel(Level.ALL);
	}
	catch (IOException e)
	{
		errorLog.log(Level.WARNING, e.getMessage(), e);
	}
}
 
开发者ID:bisguard,项目名称:bisdk,代码行数:19,代码来源:Test.java

示例12: LogService

import java.util.logging.FileHandler; //导入方法依赖的package包/类
private LogService(Logger logger) {
	super(logger);
	
	// setup a log file if the execution mode can access the filesystem (e.g. not for RA)
	// we want our logfile to look the same regardless of any user settings, so ignore 
	// a possible user logging property config file
	if (RapidMiner.getExecutionMode().canAccessFilesystem()) {
		try {
			FileHandler logFileHandler = new FileHandler(FileSystemService.getLogFile().getAbsolutePath(), false);
			logFileHandler.setLevel(Level.ALL);
			logFileHandler.setFormatter(new SimpleFormatter());
			LogService.getRoot().addHandler(logFileHandler);
		} catch (IOException e) {
			LogService.getRoot().log(Level.WARNING, "com.rapidminer.logservice.logfile.failed_to_init", e.getMessage());
		}
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:18,代码来源:LogService.java

示例13: createHandler

import java.util.logging.FileHandler; //导入方法依赖的package包/类
@SuppressLint("SimpleDateFormat")
protected FileHandler createHandler(String finalPath) throws IOException {
	FileHandler h = new FileHandler(finalPath, MAX_SIZE, 3, true);
	
	final DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
	final String sep = System.getProperty("line.separator");
	
	h.setFormatter(new Formatter() {
		
		@Override
		public String format(LogRecord r) {
			String date = format.format(new Date(r.getMillis()));
			return String.format(Locale.US, "%s [%s]: (%d) %s%s", date, r.getLevel(), r.getThreadID(), r.getMessage(), sep);
		}
		
	});
	
	h.setLevel(Level.ALL);
	return h;
}
 
开发者ID:enviroCar,项目名称:enviroCar-app,代码行数:21,代码来源:LocalFileHandler.java

示例14: config

import java.util.logging.FileHandler; //导入方法依赖的package包/类
/**
 * Configure Logger
 *
 * @throws IOException
 */
protected void config() throws IOException
{
    if( Boolean.parseBoolean(this.config.get("log_console_status", "false")) ){
        consoleHandler = new ConsoleHandler();
        log.addHandler(consoleHandler);
        if( this.config.get("log_console_level", "SEVERE").equals("ALL") ){
            consoleHandler.setLevel(Level.ALL);
        }else if( this.config.get("log_console_level", "SEVERE").equals("CONFIG") ){
            consoleHandler.setLevel(Level.CONFIG);
        }else if( this.config.get("log_console_level", "SEVERE").equals("FINE") ){
            consoleHandler.setLevel(Level.FINE);
        }else if( this.config.get("log_console_level", "SEVERE").equals("FINER") ){
            consoleHandler.setLevel(Level.FINER);
        }else if( this.config.get("log_console_level", "SEVERE").equals("FINEST") ){
            consoleHandler.setLevel(Level.FINEST);
        }else if( this.config.get("log_console_level", "SEVERE").equals("INFO") ){
            consoleHandler.setLevel(Level.INFO);
        }else if( this.config.get("log_console_level", "SEVERE").equals("OFF") ){
            consoleHandler.setLevel(Level.OFF);
        }else if( this.config.get("log_console_level", "SEVERE").equals("SEVERE") ){
            consoleHandler.setLevel(Level.SEVERE);
        }else if( this.config.get("log_console_level", "SEVERE").equals("WARNING") ){
            consoleHandler.setLevel(Level.WARNING);
        }
    }

    if( Boolean.parseBoolean(this.config.get("log_file_status", "false")) ){
        fileHandler  = new FileHandler(this.config.get("log_file_path", "src/main/java/resources/app.log"),
            Integer.parseInt(this.config.get("log_file_limit", "1")),
            Integer.parseInt(this.config.get("log_file_count", "200000")),
            Boolean.parseBoolean(this.config.get("log_file_append", "true"))
        );
        log.addHandler(fileHandler);
        if( this.config.get("log_file_level", "SEVERE").equals("ALL") ){
            fileHandler.setLevel(Level.ALL);
        }else if( this.config.get("log_file_level", "SEVERE").equals("CONFIG") ){
            fileHandler.setLevel(Level.CONFIG);
        }else if( this.config.get("log_file_level", "SEVERE").equals("FINE") ){
            fileHandler.setLevel(Level.FINE);
        }else if( this.config.get("log_file_level", "SEVERE").equals("FINER") ){
            fileHandler.setLevel(Level.FINER);
        }else if( this.config.get("log_file_level", "SEVERE").equals("FINEST") ){
            fileHandler.setLevel(Level.FINEST);
        }else if( this.config.get("log_file_level", "SEVERE").equals("INFO") ){
            fileHandler.setLevel(Level.INFO);
        }else if( this.config.get("log_file_level", "SEVERE").equals("OFF") ){
            fileHandler.setLevel(Level.OFF);
        }else if( this.config.get("log_file_level", "SEVERE").equals("SEVERE") ){
            fileHandler.setLevel(Level.SEVERE);
        }else if( this.config.get("log_file_level", "SEVERE").equals("WARNING") ){
            fileHandler.setLevel(Level.WARNING);
        }
    }
}
 
开发者ID:Clivern,项目名称:Racter,代码行数:60,代码来源:Log.java

示例15: initLogs

import java.util.logging.FileHandler; //导入方法依赖的package包/类
/**
 * 初始化日志记录
 */
private void initLogs() {
    try {
        File file = new File(System.getProperty("user.dir") + "/logs");
        if (!file.exists()) {
            file.mkdirs();
        }
        FileHandler fileHandler = new FileHandler(file.getPath() + "/log.log");
        fileHandler.setLevel(Level.ALL);
        fileHandler.setFormatter(new SimpleFormatter());
        LOGGER.addHandler(fileHandler);
    } catch (Exception ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:ajtdnyy,项目名称:PackagePlugin,代码行数:18,代码来源:MainFrame.java


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