I noticed when looking through some of the Java code at my work that when we initialise the logging framework in each class we have something like:
private final Logger log = Logger.getLogger(Foo.class);
This got me thinking, is there any reason that we use Foo.class
rather than:
private final Logger log = Logger.getLogger(this.getClass());
Is this simply a preference or is there a practical reason to prefer one over the other?
Edit: originally the code snippets referenced static members, which obviously wouldn't have compiled.