Reputation: 86757
whenever I get an unhandled exception or stacktrace output in the serverconsole, I would rather be saving this to a global logfile. And not to print it in the server console.
How can I prevent or redirect these errors?
Upvotes: 1
Views: 178
Reputation: 8205
You can change the PrintStream
instance that is set for System.err
via the method System.setErr
. However, this will redirect all output sent to System.err
to the log file.
Upvotes: 1
Reputation: 13374
Although this is not kosher on java-ee, in general, have a look at UncaughtExceptionHandler
.
In earlier days, you had to manage a threadgroup to intercept uncaught exceptions, but now you can set the default handler.
Upvotes: 0