/** * @author lautturi.com * Java example: java write stacktrace into file */ import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.*; public class Lautturi { public static void main(String[] args) throws FileNotFoundException { try { int a = 20/0; } catch (Exception e) { PrintWriter pw = new PrintWriter(new File("error.log")); e.printStackTrace(pw); pw.close(); } } }