File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Logging 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" Watch "Logging" New topic
Author

Logging

Bod Toki
Ranch Hand

Joined: Sep 01, 2006
Posts: 95
When logging in my application, do I hard code my file handler and formatter, or I rely on using the logging.properties file in the JRE?
(I have practically finished my code and haven't used logging at all - I'm guessing it might be useful to the exam accessor.)
Lucy Hummel
Ranch Hand

Joined: Apr 07, 2005
Posts: 232
Hi Bod,

I call just the default logger handler and call the normal/common methods of logger.

I do not care about properties. I do not set any properties.


----------------------------------<br />| SCJP, SCWCD, SCBCD, SCEA, SCJD |<br />----------------------------------
Bod Toki
Ranch Hand

Joined: Sep 01, 2006
Posts: 95
What parts of your code do you log?
Lucy Hummel
Ranch Hand

Joined: Apr 07, 2005
Posts: 232
Hi Bod,

I log server side stuff and some start up of the application on client side.
Brian Kelly
Ranch Hand

Joined: Jan 04, 2007
Posts: 54
There's no requirement for logging.

I didn't do any logging...


SCJA, SCJP (1.4), SCJD
chris bajada
Ranch Hand

Joined: Oct 16, 2006
Posts: 41
Brian, when you had an exception, did you show it in a console window or something? Did you have a gui for the server?
Brian Kelly
Ranch Hand

Joined: Jan 04, 2007
Posts: 54
Depends on the exception. I did the locking and unlocking in the server so the client didn't get SecurityException (trying to update a record locked with a different cookie).
Stuff like IOException/RemoteException/RecordNotFoundException were sent to the client and issued to the user (with a JOptionPane)...

I had a small GUI for the Server. When you start the server, it allows you to change the properties (like 'db file location') and start the Server. The Server GUI then quits. To stop the GUI, the user had to Crtl-C.

Just explain it in "choices.txt"...

EDIT: do you mean software exceptions??? (i.e. exceptions from buggy code?).
I didn't do anything with them. I said in "choices.txt" that there shouldn't be any software errors so I didn't try to recover from them...anyway, hiding software errors is never a good idea...
[ April 26, 2007: Message edited by: Brian Kelly ]
chris bajada
Ranch Hand

Joined: Oct 16, 2006
Posts: 41
Cool, server gui is the same as mine.

What i meant by exceptions is: do you have any catch blocks which call the exception.printStackTrace() method? If yes, that would show up in the console window of the server. However as you stated, and also in my case, the exceptions are sent to the client and they are dealt with on the client side.

Well i guess i should remove printing anything unusual in the server console window and leave everything plain simple.

Thanks for sharing your ideas bro,

Chris
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi Guys,

About the logging : the sun does not mention anything about the log - or log location, so I use the logging with its default settings, if the user want to change it he must provide a new configuration file, of course I document it (in choinces.txt). In this way I avoid any kind of possible IO problems by logging.

Chris,
the "exception.printStackTrace()" is a poor technique and it can lead you to a lot of problems. I recommend you to protocol all exception stack traces.
By example, in your times most of the people start the application with some mouse clicks on some icons not on the command line in a terminal window - so if this way the "exception.printStackTrace()" are not visible.

Regards,
M


SCJP, SCJD, SCWCD, OCPJBCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logging
 
Similar Threads
Implement or not implement the logging?
Logging: Good idea or not ?
slf4j logging issue - log file not getting generated
Best practices to do logging within a JSF application?
Setting up logging