I agree. -----Original Message----- From: Morten Hattesen [mailto:[EMAIL PROTECTED] Sent: Monday, December 11, 2006 6:22 AM To: [email protected] Subject: Suggestion - 1.3 API, Logger method signatures
Hi, The Log4J 1.3 API changes to the org.apache.log4j.Logger API was changed to allow the use of use message patterns http://logging.apache.org/log4j/docs/api-1.3/org/apache/log4j/Logger.htm l This was obviously done do avoid excessive string concatenation by the compiler when calling a logging method, as well as to make the code more legible. Example (log4j 1.2 api): logger.debug("Fetching data for " + user.name + " from database"); ... may be expressed like so in log4j 1.3: logger.debug("Fetching data for {0} from database", user.name); As a side effect it is no longer as essential to wrap calls to logging methods in a conditional ... if (logger.isDebugEnabled) { logger.debug(...); } ... since the string concatenation overhead is now not incurred unless the logging actually takes place. However, what surprises me, is that the API only supports 1 and 2 argument messages, and that message pattern is not supported at all when passing a throwable. I can see a point in allowing a single argument convenience method signature, e.g.: public void debug(Object messagePattern, Object arg); But to support multiple (2 or more) arguments (using JRE 1.2), an Object array should be used, e.g: public void debug(Object messagePattern, Object[] args); In other words, I suggest that all the two-argument methods of org.apache.log4j.Logger (and its deprecated super classes) should be removed, e.g: public void xxxx(String messagePattern, Object arg1, Object arg2); ... and replaced by ... public void xxxx(String messagePattern, Object[] args); Also, I feel that in order to keep the 1.3 API "clean" the logging methods that take a throwable argument should be overloaded with message pattern arguments, too, e.g. public void trace(Object messagePattern, Object arg, Throwable t); public void trace(Object messagePattern, Object[] args, Throwable t); Can I please get some views on this subject from other Log4J users, before submitting it formally to the developers' list. Regards, Morten Hattesen --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
