private void initLogger() { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String dateStr = formatter.format(new Date()); FileHandler fileHandler = null; try { fileHandler = new FileHandler("log/" + dateStr + "_" + getLocalName() + ".log", true); fileHandler.setFormatter(new SimpleFormatter()); } catch (IOException | SecurityException ex) { System.err.println(ex.toString()); } logger = jade.util.Logger.getMyLogger(this.getClass().getName()); logger.addHandler(fileHandler); logger.setLevel(Level.ALL); logger.setUseParentHandlers(false); // zapis tylko do pliku, coby ekranu nie śmiecić }
/** Initialization */ protected void setup() { // INitialize the logger logger = jade.util.Logger.getMyLogger(this.getClass().getName()); logger.setLevel(Logger.SEVERE); logger.info("Student agent started: " + getLocalName()); // studentNumber = (String)(String)getArguments()[0]; /** Register the agent to the directory facilitator */ DFAgentDescription dfd = new DFAgentDescription(); dfd.setName(getAID()); ServiceDescription sd = new ServiceDescription(); sd.setType(getLocalName()); sd.setName("Student Agent"); dfd.addServices(sd); try { DFService.register(this, dfd); } catch (FIPAException fe) { fe.printStackTrace(); } // Add main student agent behaviour addBehaviour(new StudentAgentBehaviour()); }