public static void addElementIntoLog(String message, boolean showOnScreen, String log) {
    	
    	if (showOnScreen) {
			System.out.println(message);
    	}
    	
		BufferedWriter out = null;
		try {
			if (log.contains(File.separator))
				new File(log).getParentFile().mkdirs();
			out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(log, (new File(log)).exists())));
			out.write(message + "\r\n");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (out != null)
					out.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
    }