This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I have some question about logging. I want to implement the simple logging without writing it to the file. And I am not sure if am I right?
I will make one parent Logger at the class, say UrlyBirdUtils. This class will be visible to all client and server classes. By default the logging level will be Level.OFF. If the properties file "suncertify.properties" is created, this log-level (OFF) will be saved in the properties.
And in every class that will need to write the logging information I will have the own instance of the log and by initialisation I will set this global Logger from URLyBirdUtilsas as the parent:
If one Exception occurs I will show the MessageDialog to user and write to log in this way:
I will not use System.out or ex.printStackTrace() at all. As the parent loger by default has Level.OFF, no information will be shown in the console. And if the examinar want to see the logs in console he/she need to set the another log-Level in "suncertify.properties" file.
And my questions are: 1. Is it okey, if I don't show any information at the console (no System.out or printStackTrace() )? 2. Do you show some information in the console? What do you show exactly? 3. Is it enough to show the log in the console, or do i need to write it into the file? 4. Is this logging idea okey?
Thanks a lot for your help and recomendations! Cheers! Olena [ May 05, 2005: Message edited by: Olena Golub ]
I don't have the URLyBird assignment, but in my assignment specs is says that all configuration must be done via a GUI. The examiner must not be required to make changes to any command line parameters or files. Therefore, according to what you said earlier:
And if the examinar want to see the logs in console he/she need to set the another log-Level in "suncertify.properties" file.
Having to change the "suncertify.properties" file would violate the instructions in my assignment. Perhaps yours is different. Just wanted to bring this to your attention.
However, I'm not using logging in my project. There is no requirement for it. I post all exceptions to System.out and popup a dialog to the user notifying them of the error. I plan to justify this approach by sighting that logging is used a good deal for debugging, so I chose not to implement it in the final submission. I hope that is an acceptable approach.
I think most of the people have done same thing. You don't have to use logging in final code. Logging is used mostly for debug purpose and in production you turn it off. You can still used in final code by allowing examiner to change it via GUI. But system.out should be good enough as we are not doing real life project and it's out of scope to do more..