aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Logging ? Printing Stack Traces ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Logging ? Printing Stack Traces ?" Watch "Logging ? Printing Stack Traces ?" New topic
Author

Logging ? Printing Stack Traces ?

Daniel Breitner
Ranch Hand

Joined: Nov 13, 2008
Posts: 70
Hello everybody,

did you use logging or did you just call printStackTrace() ?

I tend to use the stacktrace printing because there is no requirement for logging ...


Visit me at http://liferay-blogging.blogspot.com
Mxolisi Veco
Ranch Hand

Joined: Jan 14, 2010
Posts: 59
Hi Daniel.
I do not use stack trace or looging in my assignment. I do not think URLBird users will understand stack traces, and logging is not something that was required on my assignment. I just try display a relavent error message to the end user.
Daniel Breitner
Ranch Hand

Joined: Nov 13, 2008
Posts: 70
Thanks !


I decided to use a little printStackTrace() at certain points to allow administrators to look for errors.
But all the user that uses the application will see is a popup like "a technical error has occurred".
Mohiuddin Russel
Greenhorn

Joined: Mar 13, 2010
Posts: 3
Sometimes logging is useful, as example when the software is in production mode. My opinion is, at the time of development, printStacktrace is extremely helpful as you can see the error. but in the production mode, it is very helpful with logging.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5599
    
  15

Hi Daniel,

From my choices.txt:
I have used logging API in my application for debugging. I have left the logging code in all my classes, so when enhancements are made it can be reused. I have turned off all logging before submitting the project. I decided not to log any exception using the logging API, because it could be logging is turned completely off. So an exception is sent to standard error output.

And of course user will see a human-readible (and understandable) message.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Robert Benson
Ranch Hand

Joined: Apr 04, 2010
Posts: 56
Hi,
I am working through the scjd book and I am currently interested in the logging functionality:

1/ The code example in the book uses different logger's in the application classes. Why is this?. My understanding would be to use the same logger through the whole application and write everything to that.

2/ I will write my logs to a text.log using setlevel(leve.all) and switch off when the application works. Is this good practice from a tech support / audit trail point of view?

Regards, Robert.


SCJP 6 , OCMJD 6 ,
http://www.robertbenson.ie/
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5599
    
  15

Hi Robert,

1/ You could write everything to one file, but you can write to seperate loggers (like in the book): one for db, one for gui,... The main advantage is that you can change settings per logger, so your logger for db could use another logging level than the one for the gui. I used also different loggers per package.

2/ I did exactly the same. Use the logger for debugging purposes and disabled all the logging when submitting the assignment (of course I have documented this decision too). I didn't use a file, but just the console, because where are you gonna put the file? And what if that directory is write-protected for example?

Kind regards,
Roel
bernard adaba
Greenhorn

Joined: May 15, 2009
Posts: 28
i am currently fine-tuning my assignment and i must say the logging is really good for debugging purposes. I log relevant details to a file. And i hv a util package where i am putting all my log output. With this, whatever goes on from start of application to finish can be traced.

Warmest regards
Bernard


SCJP 5, SCJD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logging ? Printing Stack Traces ?