're-directing" System.err

Discussion in 'Java' started by Roy Epperson, Nov 8, 2003.

  1. Roy Epperson

    Roy Epperson Guest

    I've written a GUI application that might throw un-handled exceptions when
    users are using it in some modes. The application is started by a separate
    executable so there is no command line/window for System.err to show up in.

    Is there a way to re-direct System.err so any exceptions get logged to a
    file, say in user.home?

    TIA,
    Roy
     
    Roy Epperson, Nov 8, 2003
    #1
    1. Advertisements

  2. Roy Epperson

    Ben_ Guest

    What about System.setErr() ?

    Or you may want to use a logging API (Apache log4J or JDK 1.4's Logging API,
    for example).
     
    Ben_, Nov 8, 2003
    #2
    1. Advertisements

  3. "Roy Epperson" <> writes:

    > Is there a way to re-direct System.err so any exceptions get logged to a
    > file, say in user.home?


    Use System.setErr() on a stream to that file.
     
    Tor Iver Wilhelmsen, Nov 8, 2003
    #3
  4. Roy Epperson

    Roy Epperson Guest

    Thanks for the pointers. I missed System.setErr() somehow....

    "Roy Epperson" <> wrote in message
    news:zpZqb.1959$...
    > I've written a GUI application that might throw un-handled exceptions when
    > users are using it in some modes. The application is started by a

    separate
    > executable so there is no command line/window for System.err to show up

    in.
    >
    > Is there a way to re-direct System.err so any exceptions get logged to a
    > file, say in user.home?
    >
    > TIA,
    > Roy
    >
    >
     
    Roy Epperson, Nov 10, 2003
    #4
  5. Roy Epperson

    Andrew Guest

    You use the System.setErr( PrintStream ) method. Consult the API
    documentation on how to create a java.io.PrintStream object and
    redirect its output to a log file.

    I will probably regret replying to this post. The last time I replied
    to a Usenet post I recieved spam and trojan-laden email for about a
    week. Oh, well. I guess I'll deal with it.

    "Roy Epperson" <> wrote in message news:<zpZqb.1959$>...
    > I've written a GUI application that might throw un-handled exceptions when
    > users are using it in some modes. The application is started by a separate
    > executable so there is no command line/window for System.err to show up in.
    >
    > Is there a way to re-direct System.err so any exceptions get logged to a
    > file, say in user.home?
    >
    > TIA,
    > Roy
     
    Andrew, Nov 11, 2003
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rhino
    Replies:
    0
    Views:
    1,761
    Rhino
    Nov 13, 2004
  2. Replies:
    0
    Views:
    546
  3. Will Lichtenberger
    Replies:
    3
    Views:
    3,788
    dener
    Nov 5, 2008
  4. Mike Schilling

    System.out and System.err

    Mike Schilling, Oct 1, 2008, in forum: Java
    Replies:
    14
    Views:
    1,066
    Arne Vajhøj
    Oct 11, 2008
  5. Terry Cooper
    Replies:
    7
    Views:
    589
    Janos Sebok
    Jun 9, 2009
  6. Replies:
    1
    Views:
    713
  7. Replies:
    1
    Views:
    555
    Roedy Green
    Aug 29, 2012
  8. Replies:
    0
    Views:
    478
Loading...