DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16229>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16229 Convenience methods to cut execution speed in application code Summary: Convenience methods to cut execution speed in application code Product: Log4j Version: 1.2 Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Enhancement Priority: Other Component: Other AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] In my application (ArgoUML) there are a lot of places where log4j is called with the debug level. Some of them are like this (actual examples): cat.debug("applying critic: " + _headline); ... cat.debug(d + " " + d.getPriority()); ... Configuration.cat.debug("key '" + key + "' returns '" + result + "'"); This all seems very harmless, and most of my developers don't (and shouldn't) hesitate in adding such lines to the code. Now let me tell you that my profilation of the application lead to the fact that the first line was doing 18% of all memory allocation as innocent as it may seem (with debug turned off). The log4j faq suggests that we should replace cat.debug("we now have " + value) with if (cat.isDebugEnabled()) { cat.debug("we now have " + value); } but this code really makes the log4j-calls stand out and clutter the application code. Let me suggest that the following convenience methods (with friends) are added to the Logger class to fix this problem (I am not sure this exact implementation work but I hope you get the general idea): void debug(Object mess1, Object mess2) { if (isDebugEnabled()) { debug("" + mess1 + mess2); } } void debug(Object mess1, Object mess2, Object mess3) { if (isDebugEnabled()) { debug("" + mess1 + mess2 + mess3); } } void debug(Object mess1, Object mess2, Object mess3, Object mess4) { if (isDebugEnabled()) { debug("" + mess1 + mess2 + mess3 + mess4); } } void debug(Object mess1, Object mess2, Object mess3, Object mess4, Object mess5) { if (isDebugEnabled()) { debug("" + mess1 + mess2 + mess3 + mess4 + mess5); } } These would allow me to write the code like this: cat.debug("applying critic: ", _headline); ... cat.debug(d, " ", d.getPriority()); ... Configuration.cat.debug("key '", key, "' returns '", result, "'"); a beautiful and efficient implementation. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>