commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Dever" <jdev...@nortelnetworks.com>
Subject [httpclient] logging policy
Date Fri, 26 Jul 2002 17:30:20 GMT

Some suggestions to be applied across the HttpClient package.  These are in
addition to, and in conjunction with, the best practices section of the
commons-logging userguide.
http://cvs.apache.org/viewcvs/jakarta-commons/logging/usersguide.html

This is in response to the logging feature in HttpClient:
http://issues.apache.org/bugzilla/show_bug.cgi?id=10804

Please comment on the suitability of these points, the addition of others.


1) Log the entry to every method at the trace level.  (exits not required
due to difficulty in determing exit points)
	log.trace("enter SomeClass.SomeMethod(Class, Class)");

2) Only/always log exception stack traces at the debug level
	} catch (Exception ex) {
	    log.debug

3) Any swallowed exceptions should log the exception at the debug level
	try {
	    thread.sleep();
	} catch (InterruptedException ie) {
	    //expected
	    log.debug("Caught interrupted exception");
	}

4) Error,Warn,Info messages should be suitable for users to view.  Code
specific details should be kept to Debug and Trace. 

5) instantiate one static logger per class like this:
	private static final Log log = LogFactory.getLog(CLASS.class);

6) Any messages that are passed over an open network connection should be
logged on the wirelog:
	private static final Log wireLog =
LogFactory.getLog("httpclient.wire");

7) Any logging statement that causes other method calls in the construction
of its arguments must be protected by a isXXXEnabled() conditional (except
when already protected by a try/catch block):
	if (log.isDebugEnabled() {
	    log.debug("some text" + someVar + "some more text");
	}
	try {
	    //some code
	} catch (Exception ex) {
	    log.warn("Failed to execute some code: " + ex.getMessage());
	    log.debug("Unexpected exception caught", ex);
	}

8) At this point there will be no internationalization of logging messages,
but it may be added in the future.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message