public static void logException(Exception ex) {
        try {
            File exLog = new File(filePath);
            FileOutputStream outputStream = new FileOutputStream(exLog);
            ex.printStackTrace(new PrintStream(outputStream));
            outputStream.flush();
            outputStream.close();

        } catch (IOException ioE) {
            System.exit(1);
        }
    }