List of usage examples for java.util.logging FileHandler FileHandler
public FileHandler(String pattern, int limit, int count) throws IOException, SecurityException
From source file:Logi.GSeries.Service.LogiGSKService.java
/** * @param args the command line arguments *//* ww w.j a v a2 s . c om*/ public static void main(String[] args) { SystemTray.DEBUG = false; Settings settings; if (IOOperations.currentSettingsExist()) { settings = IOOperations.loadCurrentSettingsObjectFromFile(); } else { settings = new Settings(); } LogiGSKService l = new LogiGSKService(); if (settings.getShowSystemTray()) { l.showSystemTray(); } else { l.hideSystemTray(); } l.begin(); try { String dataFolderPath = IOOperations.getLocalDataDirectoryPath(); File dataFolder = new File(dataFolderPath); if (!dataFolder.exists()) { dataFolder.mkdir(); } String logFolderPath = IOOperations.getLogDirectoryPath(); File logFolder = new File(logFolderPath); if (!logFolder.exists()) { logFolder.mkdir(); } FileHandler fileHandler = new FileHandler(logFolderPath + "LogiGSK.log", FILE_SIZE, 3); fileHandler.setLevel(Level.ALL); logger.setLevel(Level.ALL); logger.addHandler(fileHandler); } catch (IOException | SecurityException ex) { Logger.getLogger(LogiGSKService.class.getName()).log(Level.SEVERE, null, ex); } int clientNumber = 0; ServerSocket listener = null; PropertyConfigurator.configure(LogiGSKService.class.getResource("/Logi/GSeries/Service/log4j.properties")); reloading = true; boolean firstTime = true; while (reloading) { listener = null; if (reloading && !firstTime) { if (IOOperations.currentSettingsExist()) { settings = IOOperations.loadCurrentSettingsObjectFromFile(); } else { settings = new Settings(); } } firstTime = false; reloading = false; running = true; try { listener = new ServerSocket(settings.getPort(), 0, InetAddress.getByName(null)); while (running) { new Manager(listener.accept(), clientNumber++, logger).start(); } } catch (IOException ex) { Logger.getLogger(LogiGSKService.class.getName()).log(Level.SEVERE, null, ex); } finally { if (listener != null) { try { listener.close(); } catch (IOException ex) { Logger.getLogger(LogiGSKService.class.getName()).log(Level.SEVERE, null, ex); } } } } }
From source file:com.flagleader.builder.FlagLeader.java
public static void main(String[] paramArrayOfString) { Shell localShell = new Shell(16777216); localShell.setLocation(new Point(300, 200)); localShell.setLayout(new FillLayout()); Composite localComposite = new Composite(localShell, 0); localComposite.setLayout(new FillLayout()); Label localLabel = new Label(localComposite, 0); Image localImage = ImageDescriptor .createFromURL(localShell.getClass().getClassLoader().getResource("icons/start.jpg")).createImage(); localLabel.setImage(localImage);/*ww w. j a v a 2s . c om*/ localShell.setSize(400, 300); localShell.setText("Visual Rules Solution"); localShell.open(); Init.a(); String str = null; if (BuilderConfig.getInstance().isLoadDefault()) str = RuleRepository.DEFAULTEXT; if (paramArrayOfString.length > 0) str = ""; for (int i = 0; i < paramArrayOfString.length; i++) str = str + paramArrayOfString[i] + " "; Logger localLogger = Logger.getLogger("ruleengine"); Object localObject; try { new File(SystemUtils.USER_HOME + File.separator + ".visualrules" + File.separator + "logs").mkdirs(); FileHandler localFileHandler = new FileHandler(SystemUtils.USER_HOME + File.separator + ".visualrules" + File.separator + "logs" + File.separator + "logfile%u.%g.txt", 0, 10); localFileHandler.setFormatter(new com.flagleader.server.c()); localFileHandler.setLevel(Level.ALL); Logger.getLogger("flagleader").addHandler(localFileHandler); localLogger.addHandler(localFileHandler); } catch (Exception localException1) { if (!b) { localObject = new ConsoleHandler(); ((ConsoleHandler) localObject).setFormatter(new com.flagleader.server.c()); ((ConsoleHandler) localObject).setLevel(Level.ALL); Logger.getLogger("flagleader").addHandler((Handler) localObject); localLogger.addHandler((Handler) localObject); } } if (!BuilderManager.checkLicense()) { localImage.dispose(); localShell.dispose(); return; } Property.getInstance().setEngineImplement("com.flagleader.engine.impl.SingleRuleEngineFactory"); FlagLeader localFlagLeader = new FlagLeader(); Property.getInstance().setUpdateInternateTime(0L); localFlagLeader.setBlockOnOpen(true); localFlagLeader.builderManager = new BuilderManager(localFlagLeader); if ((com.flagleader.manager.d.c.a("needLogin", false)) || (BuilderConfig.getInstance().isFirstLogin())) try { localObject = localFlagLeader.builderManager.getUserServer(); if ((localObject == null) || (((String) localObject).length() == 0) || (localFlagLeader.builderManager.getUserType() == 0) || (localFlagLeader.builderManager.getUserid() == 0)) { localImage.dispose(); localShell.dispose(); return; } } catch (Exception localException2) { MessageDialog.openError(null, "", ResourceTools.getMessage("loginserver.error") + localException2.getLocalizedMessage()); localImage.dispose(); localShell.dispose(); return; } if ((str != null) && (new File(str).exists())) localFlagLeader.builderManager.getRulesManager().a(new File(str)); localFlagLeader.initWindow(); if (new File(SystemUtils.JAVA_IO_TMPDIR, "engine.jar").exists()) new File(SystemUtils.JAVA_IO_TMPDIR, "engine.jar").delete(); if (new File(SystemUtils.JAVA_IO_TMPDIR, "export.jar").exists()) new File(SystemUtils.JAVA_IO_TMPDIR, "export.jar").delete(); if (BuilderConfig.getInstance().isAutosave()) new com.flagleader.builder.d.c(localFlagLeader.builderManager).b(); if (BuilderConfig.getInstance().isAutoCheckVersion()) new a(localFlagLeader.builderManager).b(); new e().b(); localImage.dispose(); localShell.dispose(); localFlagLeader.open(); BuilderManager localBuilderManager = localFlagLeader.builderManager; localFlagLeader.getShell().addShellListener(new d(localBuilderManager)); }
From source file:com.eddy.malupdater.MalUpdater.java
public static void initMainLogger() throws IOException { Handler handler = new FileHandler("error.log", 8096, 1); Logger.getLogger("com.eddy.malupdater").addHandler(handler); }
From source file:org.mitre.eren.action.ActionManager.java
public ActionManager(String[] args) { // parse the arguments int serverPort = 3737; String endpoint = "http://erenbus.mitre.org:3732/"; Abdera abdera = Abdera.getInstance(); factory = abdera.getFactory();//from w ww .j a v a2 s .co m factory.registerExtension(new ActionExtensionFactory()); log.info("finished factory configuration"); try { Options options = new Options(); options.addOption("p", "port", true, "Server port to listen on for incoming HTTP messages from the bus"); options.addOption("u", "url", true, "Outbound URL to post HTTP messages to"); options.addOption("l", "log", true, "Path to logfiles"); options.addOption("f", "file", true, "location of action file to parse"); options.addOption("c", "class", true, "this is ignored"); options.addOption("h", "help", false, "Prints this help message"); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args, true); if (cmd.hasOption("h")) { HelpFormatter hf = new HelpFormatter(); hf.printHelp("ERENAction.jar", options); System.exit(1); } if (cmd.hasOption("p")) { serverPort = Integer.parseInt(cmd.getOptionValue("p")); } if (cmd.hasOption("u")) { endpoint = cmd.getOptionValue("u"); } if (cmd.hasOption("l")) { String logfile = cmd.getOptionValue("l"); FileHandler fh; try { fh = new FileHandler(logfile + "action%g.log", 10000000, 5); log.addHandler(fh); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (cmd.hasOption("f")) { String fileName = cmd.getOptionValue("f"); actionFile = readActionFile(fileName); } } catch (ParseException e) { // TODO Auto-generated catch block log.log(Level.WARNING, "Caught Exception", e); } catch (FileNotFoundException fnf) { log.log(Level.SEVERE, "Couldn't read ActionFile", fnf); fnf.printStackTrace(); } // Start the server messageProcessor = new InboundActionHttpController(this); // InboundHttpEndpoint server = new InboundHttpEndpoint(serverPort, new InboundMessageHandler(messageProcessor)); // Thread st = new Thread(server, "EREN HTTP Inbound Endpoint"); // //st.setDaemon(true); // st.start(); // client = new OutboundHttpEndpoint(endpoint); // client.registerExtension(new EDXLRMExtensionFactory()); // client.registerExtension(new StartupExtensionFactory()); if (actionFile != null) { log.log(Level.INFO, actionFile.toString()); } }
From source file:org.mitre.eren.model.ModelManager.java
public ModelManager(String[] args) { myQueue = new LinkedBlockingQueue<Element>(); // parse the arguments int serverPort = 3737; String endpoint = "http://erenbus-gertner.mitre.org:3732/"; try {/*from w ww .j a v a 2 s . co m*/ Options options = new Options(); options.addOption("p", "port", true, "Server port to listen on for incoming HTTP messages from the bus"); options.addOption("u", "url", true, "Outbound URL to post HTTP messages to"); options.addOption("l", "log", true, "Path to logfiles"); options.addOption("s", "scale", true, "Population scale factor. The populations from the scenario file are divided by this number"); options.addOption("c", "class", true, "this is ignored"); options.addOption("h", "help", false, "Prints this help message"); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args, true); if (cmd.hasOption("h")) { HelpFormatter hf = new HelpFormatter(); hf.printHelp("ERENModel.jar", options); System.exit(1); } if (cmd.hasOption("p")) { serverPort = Integer.parseInt(cmd.getOptionValue("p")); } if (cmd.hasOption("u")) { endpoint = cmd.getOptionValue("u"); } if (cmd.hasOption("s")) { scaleFactor = Integer.parseInt(cmd.getOptionValue("s")); } if (cmd.hasOption("l")) { String logfile = cmd.getOptionValue("l"); FileHandler fh; try { fh = new FileHandler(logfile + "model%g.log", 10000000, 5); log.addHandler(fh); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } catch (ParseException e) { // TODO Auto-generated catch block log.log(Level.WARNING, "Caught Exception", e); } // Start the server messageProcessor = new InboundModelHttpController(this); // InboundHttpEndpoint server = new InboundHttpEndpoint(serverPort, new InboundMessageHandler(messageProcessor)); // Thread st = new Thread(server, "EREN HTTP Inbound Endpoint"); // //st.setDaemon(true); // st.start(); // build the client this.delayedEventQueue = new PriorityBlockingQueue<DelayedEvent>(); this.eventQueue = new LinkedBlockingQueue<Event>(); Thread qt = new Thread("EREN Model Event Queue") { @Override public void run() { while (true) { try { Event e = eventQueue.take(); e.getStateMachine().fireEvent(e.getEventName()); } catch (InterruptedException e) { } } } }; qt.start(); // client = new OutboundHttpEndpoint(endpoint); // client.registerExtension(new EDXLRMExtensionFactory()); // client.registerExtension(new StartupExtensionFactory()); resourceHolder = new ResourceHolder(client, sender); }