In Alain's book Java 2 Developer Exam Cram 2, the following tip is on p. 128 regarding logging.
You can justify logging in your application because one of the key certification requirements is error handling, one of the original motivations for logging. However, you can also use logging strictly for debugging. If you do, you can either turn it off or remove it before submitting your project. Logging is not specifically required for the certification project, but neither are buttons. If you include logging in your project, you have the option to leave it in your submission (it won't count against you) or to remove it to eliminate the risk of a logging error (for example, can't open a log file).
Based on this, and if it is not really required, I had originally planned to leave it out. Other reasoning to defend that logging is not needed would be that for the GUI, my controller catches all the appropriate errors and gives the user a friendly alert box. For the implemented data methods that are not used in the GUI, the exception thrown would include an appropriate message. I am just wondering if the above reasoning is correct, or if I would potentially lose marks for not including logging. Thoughts? TJ
I log both to the console and a file. I found logging to be invaluable for debugging and proving to myself that my locking design behaved the way I believed it did. I've heard it said previously (I think by Max) that you should turn off the file logging prior to submission as it's just one more thing that can potentially go wrong when the submission is being graded. I think that's probably very good advice. In any case, I never would have got my locking working correctly without using logging, so I highly recommend using it. Also, as regards the Alain Trottier book, please see the book review in the javaranch bunkhouse. Or, search through this forum for Alain Trottier and read some of the comments SCJDer's have made about some of the code examples in that book. If you haven't taken a look at Max's book (referenced in his post above) you owe it to yourself to do so. I found it to be even more valuable than logging. As an added bonus the author can often be found on this forum answering questions. Hope this helps, George [ January 07, 2004: Message edited by: George Marinkovich ]
SCJP, SCJD, SCWCD, SCBCD
posted 16 years ago
Thanks George and Max. I am using the console type logging for testing, and agree with George that it is invaluable to get the stuff working. I am just hoping to minimize risk by avoiding file logging. George - I do have Max's book too, and it is also invaluable. So, I will carry on with my console logging only. TJ
If your applicatiion uses an optional logging config file (see how to do it here), you can still log to a file for debugging purposes during development (can be handy), and - without *any* change in your code - only log to the console (and possibly with other levels BTW) in your submitted application as Max suggests above. Regards, Phil.
I have been using log4j for a long time, both with file appenders and both with console appenders. Logfactor5 is a really great frontend that provides a great and convenient way to browse the logs. After using it for 5 days you get addicted to it. You can easily filter which sources you want to see the logs from, which levels are you interested in - and logging becomes right much more friendly. I do know that log4J cannot be used on the exams provided by the sun , and I really like the logging concept introduced in 1.4, but I haven't seen a similar GUI frontend which could fascilitate the browsing of the logs. I use Ant, JUnit and I am currently using log4j because it helps me a lot - much faster than debugging. I forward the logging to a file, because after running the daily build which includes the JUnit tests I can see the conversation of my classes in a developer friendly, filterable GUI(lf5). log4j.properties:
Later on I will change the import statements to use the Logger included in 1.4. If I can found any smart frontend for 1.4 (I am sure that it is already being developed) then I switch immeditely to sun's solution and I will change the configuration file for the logging, too.
Ignoring logging means to turn off the laudspeaker of your application. It is a significant part of the socalled Safe Programming.
Best wishes, Dori P.S. Why does this mail gets so wide? I made it the same way as usual.. [ January 08, 2004: Message edited by: Dora Gal ] [ January 08, 2004: Message edited by: Dora Gal ] [ January 09, 2004: Message edited by: Dora Gal ]
Originally posted by Dora Gal: P.S. Why does this mail gets so wide? I made it the same way as usual..
Because of your code sample above. When you type your normal responses, or quote someone else, UBB (the software running this forum) will try and wrap the text to fit the page. But if you put code into your post, UBB will not wrap the code block. This is normally a good thing, but if your code line is too long, it can cause this really wide page situation. Normally I would try and manually adjust the line of code that causes this effect, but since your line appears to be from a configuration file, I suspect that wrapping the line would cause it to fail. I am not sure that this would really cause a problem (as you noted, you cannot use log4j in the assignment), but I don't want to do it in case someone is currently using log4j and tries your configuration then complains that it doesnt work. Regards, Andrew
Hi Andrew, I will try to change it somehow. I would not use log4j (during the dev.) unless I found a smart GUI browser of the config files provided by 1.4 logging FW. Have you ever seen sg. like logFactor5 or Chainsaw for the logging FW? Regards, d [ January 09, 2004: Message edited by: Dora Gal ]
The only thing that kept the leeches off of me was this tiny ad: