Peter Johnson [https://community.jboss.org/people/peterj] created the discussion

"Re: Looking for good Java source code examples of error handling and logging"

To view the discussion, visit: https://community.jboss.org/message/724716#724716

--------------------------------------------------------------
Good example of logging and exception handling? Well, if you mean the ability 
to use logging to output stuff, including excpetion stack traces, I guess that 
fits. But if you mean providing meaningful information to users of the 
application server, then no. The developers apparently never took a writing 
class in school, or perhaps they weren't paying attention, or perhaps they 
thought that lessons learned in that class did not pertain to logging output. 
Whatever it was, they forgot a fundamental principle of writing: know your 
audience. Based on what i have seen as far as logging and exception error 
messages are concerned, they have no idea who their audience is. They think is 
is themselves. It really should be system administrators managing numerous 
application servers and developers trying to debug their own applications.

As an example, look at the log messages that show up on the console when you 
start JBoss AS. Which of those messages are really of importance to a system 
administrator. Or even a programmer deploying their app? Very few. You end up 
having to sift through useless stuff to get at important stuff. And there is 
some important stuff that never gets logged (for example, the log used to tell 
you which port JNDI the app server was using, a useful piece of information, 
but that log message disappeared at one point.)

Browse through the forums and you will find numerous examples of:
a) False error messages. People post exception stack traces or other error 
messages and want to know what they did wrong, when the answer is nothing, it 
is a debug message, or a warning that can be ignored. 
b) Unfathomable error messages. People post exception stack traces that show up 
when deploying their application, or while running their application, and they 
have no idea what went wrong because the error message is written for 
theprogrammer who wrong the code that threw the exception. So the error message 
means something to someone on the JBoss AS team, but everyone else is clueless. 
(The deployment error report printed at the end of startup when there are 
deployment error is one of the most misunderstood output artifacts mainly 
because while it looks like a defintive reasource about deployment errors, it 
rarely, if ever, contains any useful information.)

Sorry for the rant, but logging is one of those things that has bugged me a 
long time. Some open source projects do it better than others (Ant and Maven 
are examples - with a standard level of logging you get informative messages 
about the steps in your build), but most have the same issues.

So if you want to do logging right, talk to your audience. Find out what they 
need and want. Log that information for them. If your developers want to use 
logging as a means to debug their own code, make sure that their logging output 
doesn't contaminate the logs presented to end users.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/724716#724716]

Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]

_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to