I think the common idiom for creating instances of java.util.logging.Logger
is this:
public class SomeClassName {
private static final Logger LOG = Logger.getLogger(SomeClassName.class.getName());
}
My IDE will manage changing the line appropriately when I refactor my code (change the name of the class, for example). It still bugs me that I have to repeat the name of the class, though. What I'd really like to do is something like Logger.getLogger(getName())
or Logger.getLogger(class.getName())
, but this isn't legal Java in a static initilization.
Is there a better way of getting at a logger that doesn't involve repeating myself?