private static void initLogger() {
		logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
		logger.setLevel(Level.ALL);
		logger.setFilter(null);
		logger.setUseParentHandlers(false);
		Formatter fNotVerySimple = new  Formatter() {
			@Override
			public String format(LogRecord record) {
				Throwable a = record.getThrown();
				if (a == null) return String.format(record.getMessage(), record.getParameters());
				StringBuilder result = new StringBuilder(500);
				result.append(record.getLevel().toString()+": "+record.getMessage());
				result.append(a.toString()+"\n");
				for (StackTraceElement trace: a.getStackTrace())
					result.append("\tat "+trace.toString()+"\n");
				return result.toString();
			}
		};
		if (logToCon) {
			Handler hConsole = new StreamHandler(System.out,fNotVerySimple) {
				public void publish(LogRecord record) {
					super.publish(record);
					flush();
				}
			};
			hConsole.setLevel(Level.INFO); // only essentials
			logger.addHandler(hConsole);
		}
		if (logToFile) {
			try {
				Handler hFile = new FileHandler(logFile);
				hFile.setFormatter(fNotVerySimple);
				hFile.setLevel(Level.ALL);
				logger.addHandler(hFile);
			} catch (SecurityException|IOException e) {
				logger.log(Level.SEVERE, "", e);
			}
		}
		
	}