Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The way of logging exception

 
Roman Yankin
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to know your opinion if the following approach is fair to use.

Consider the exception that you can do nothing but log, e.g. IOException. When it fires I have the following code to handle it:



logError in turn opens JOptionPane notifies the user with information that can be extracted from e.getMessage() and calls Here log is an instance of java.util.logging.Logger

I wonder if such approach is OK, or something can/must be improved?
 
David Winters Junior
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roman,

I have a log file for each class in the project so that if an exception occurs then i log it to the log file and the in the catch block throw the exception. You should define verious exceptions at each layer, the server layer, gui layer of the application etc.

So in order to have a log file for each class - i created a Logger class which will be instantiated when each class is instantiated. It is good for debugging
and is closer to a real world solution for logging here.

I hope this helps
David
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic