• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX: Logging and Alain Trottier book

 
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suggest that you log, but only to the console.
M
[ January 07, 2004: Message edited by: Max Habibi ]
 
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Phil, I'll check it out.
TJ
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dora,

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
 
Dora Gal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic