I have written a code. But I found everytime it written the error into log file, it will totally cover the existed file, not to appended after it. What happened...
try {
            int s = 1 / 0;
        } catch (Exception e) {
            try {
                Date d = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                SimpleDateFormat sd = new SimpleDateFormat("yyyy_MM_dd");
                String s = sdf.format(d);
                String day = sd.format(d);
                PrintStream ps = new PrintStream("src/log/"+day+"_Exception.log");
                ps.println(s);
                System.setErr(ps);
            } catch (Exception e2) {
            }
            e.printStackTrace(System.err);
        }
 
    