Cómo obtener el contenido de e.printStackTrace y registrarlo en el registro log4j
El código fuente es el siguiente: Probado correctamente
import java.io.*;
la clase pública ThrowableTest extiende FileNotFoundException {
public static void main(String argv[]) {
prueba {
FileInputStream f = new FileInputStream("D:\\test.txt");
} catch (FileNotFoundException e) {
prueba {
PrintWriter p = new PrintWriter(new FileOutputStream("D:\\errors.txt"));
p.println("=== toString() ===");
p.println(e.toString()+"\n");
p .println ("=== getLocalizedMessage() ===");
p.println(e.getLocalizedMessage());
p.println("=== getMessage () ===\n");
p.println(e.getMessage());
p.println("=== printStackTrace() ==="
e.printStackTrace(p);
p.flush();
} captura (IOException e1) {
e1.printStackTrace();
}
}
}
}