Platinum Partner

Class Rename Friendly Log Instance

Use the following to automatically use the current class name for the log category (example is for commons-logging, works with log4j, too):


class Foo {
   private final Log log = LogFactory.getLog(getClass());
}


Compare to the following where the class name is refered to explicitely. If the class is renamed or parts of the codes are copied ("reused") the logging will by misleading.


class Foo {
   private static final Log log = LogFactory.getLog(Foo.class);
}



{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}