In the given example, the log message is a constant string, so letting the logger discard it is just as efficient as checking whether the logger is enabled, and it lowers the complexity of the code because there are fewer branches.
However it is worth adding the log.isDebugEnabled() in case string is not a constant. On Thu, Aug 27, 2015 at 8:38 AM, Afkham Azeez <[email protected]> wrote: > Yes, but it won't improve the performance a great deal > On Aug 27, 2015 5:21 AM, "Vanjikumaran Sivajothy" <[email protected]> wrote: > >> Hi Devs, >> >> I have seen most of the code in the WSO2 code repo is making use >> of log.isDebugEnabled() [1] every time before it debug log. >> >> Why do not we introduce a instance variable and make use of that variable >> to check the debug flag? >> >> >> >> >> [1] >> if (*log.isDebugEnabled()*) { >> log.debug("Log XXXXXX"); >> } >> if (*log.isDebugEnabled()*) { >> log.debug("Log YYYYYY"); >> } >> >> >> [2] >> boolean isDebugEnabled = *log.isDebugEnabled();* >> if (isDebugEnabled) { >> log.debug("Log XXXXXX"); >> } >> if (isDebugEnabled) { >> log.debug("Log YYYYYY"); >> } >> >> -- >> Vanjikumaran Sivajothy >> *Associate Technical Lead* >> *WSO2 Inc. http://wso2.com <http://wso2.com/>* >> *USA Mobile **+1-812-361-1286* >> *Srilanka Mobile:+94-777-219-209* >> [image: Facebook] <https://www.facebook.com/vanjikumaran> [image: >> Twitter] <https://twitter.com/vanjikumaran> [image: LinkedIn] >> <http://www.linkedin.com/pub/vanjikumaran-sivajothy/25/b31/293> [image: >> Blogger] <http://vanjikumaran.blogspot.com/> [image: SlideShare] >> <http://www.slideshare.net/vanjikumaran> >> >> This communication may contain privileged or other >> confidential information and is intended exclusively for the addressee/s. >> If you are not the intended recipient/s, or believe that you may >> have received this communication in error, please reply to the >> sender indicating that fact and delete the copy you received and in >> addition, you should not print, copy, re-transmit, disseminate, or >> otherwise use the information contained in this communication. >> Internet communications cannot be guaranteed to be timely, secure, error >> or virus-free. The sender does not accept liability for any errors >> or omissions >> > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Best Regards, Malaka Silva Senior Tech Lead M: +94 777 219 791 Tel : 94 11 214 5345 Fax :94 11 2145300 Skype : malaka.sampath.silva LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77 Blog : http://mrmalakasilva.blogspot.com/ WSO2, Inc. lean . enterprise . middleware http://www.wso2.com/ http://www.wso2.com/about/team/malaka-silva/ <http://wso2.com/about/team/malaka-silva/> Save a tree -Conserve nature & Save the world for your future. Print this email only if it is absolutely necessary.
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
