*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Logging: Good idea or not ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Logging: Good idea or not ?" Watch "Logging: Good idea or not ?" New topic
Author

Logging: Good idea or not ?

John Donoghue
Ranch Hand

Joined: Dec 20, 2007
Posts: 45

I was wondering what people thought about logging. The Monkhouse & Camerlengo book includes it. On the other hand, it clutters the code and decreases readability. It isn't a requirement, and is a place to lose points it you make a silly mistake (like inconsistent names or misconfigure a class and sending a bunch of logging output to the standard output/error). So do people think it is a good idea on balance?

Thanks,

John
[ December 27, 2007: Message edited by: John Donoghue ]

SCJP 5<br />SCBCD 1.3<br />SCJD<br />SCWCD 1.4, 5<br />SCBCD 5 -- working on it
Jonathan Wolter
Greenhorn

Joined: Nov 26, 2007
Posts: 12
I am using logging, and I will include it in my final submission. I even wrote my own logging formatter (OneLineLogFormatter) to make the log file more readable.

Benefits I see outweigh the costs.

Logging clarifies the Concurrency code, and makes for better understood code, imho.

jaw
John Donoghue
Ranch Hand

Joined: Dec 20, 2007
Posts: 45

Thanks for the reply. I will use logging.
Also, sorry of for all the typos in the original message. My thumbs are way bigger than the keys on that stupid Blackberry.


-John
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Originally posted by John Donoghue:
On the other hand, it clutters the code and decreases readability.
Hmmm - maybe. The same argument could be used against including comments. I personally find that a well placed log message will work instead of a comment when I am reading the code, and simultaneously give me good debugging information when I am trying to look at a run that has a problem.
Originally posted by John Donoghue:
It isn't a requirement,
Very true, and we do argue several times throughout the book that going beyond the requirements can be against your best interests (and there is even a comment to that effect in your instructions). I personally feel that this is one area where a little step outside the minimum requirements is actually a good thing, and shows a little more professionalism.
Originally posted by John Donoghue:
...and is a place to lose points it you make a silly mistake

True.
Originally posted by John Donoghue:
...(like inconsistent names ...

Perhaps - I think this sort of problem could happen even just as easily with comments in the code, so I don't see it as a particular problem.
Originally posted by John Donoghue:
or misconfigure a class and sending a bunch of logging output to the standard output/error).

I think this is possibly a reason for the logging - these sorts of errors will then be apparent when you run the application, rather than when the assessor steps through your code.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
John Donoghue
Ranch Hand

Joined: Dec 20, 2007
Posts: 45

Andrew,

Thanks for taking the time to respond. I have been waffling about this for a while, but in the past week I've hit a couple of places where the having the logging code would help, so I believe that you are correct.

-John

BTW: I love the book. Thanks to you and Terry for writing it.
[ January 01, 2008: Message edited by: John Donoghue ]
 
 
subject: Logging: Good idea or not ?
 
Similar Threads
Logger
Logging in Java
General uneasy feeling about java logging...... or maybe it's just too much eggnog
Exception throwing
log & throw antipattern