Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

redirect exception output to file ?

Posted on 1999-08-06
3
Medium Priority
?
207 Views
Last Modified: 2011-09-20
Hi,

is it possible to redirect the output of printStackTrace(...) of Throwable to a file ?
Maybe by overriding PrintStream or PrintWriter ?

Thanks, JFM.
0
Comment
Question by:JFM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
jasbro earned 200 total points
ID: 1247821
Yes, when you create your PrintStream, pass it a FileOutputStream as the output stream argument.
0
 
LVL 2

Expert Comment

by:jasbro
ID: 1247822
similar to:
  PrintStream ps = new PrintStream(new FileOutputStream("error.log"));
  try{
    code that throws exception
   }
  catch(Exception e){
      e.printStackTrace(ps);
   }
0
 

Author Comment

by:JFM
ID: 1247823
Works good, thanks :-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question