How to send exception to log4j log from java swing ?
We have much code already done and it does a lot of:
mytable.getSelectionModel().addListSelectionListener(
new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
... no try catch
}
});
There is no try/catch. App sends npe exception to console. We need it in log4j. But don’t want to change all this code (100s of line like this). What can we do?
You can set up an uncaught-exception handler that will log anything thrown by your application.
In the main method of your Swing app add these lines:
Then implement the exception-handler like this: