Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

getting the class name from static context

807603Feb 18 2008 — edited Feb 18 2008
I've seen this pattern in lots of Java code over the years, and it's always sort of bugged me:

private static Logger logger = Logger.getLogger([class name].class.getName());

I�d like to be able to do �this.getClass().getName()�; that way if I ever decide to change the name of the class there�s one less line of code to worry about.

Is it just me, or does it seem like a deficiency in Java that should be corrected?

- Michael
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 17 2008
Added on Feb 18 2008
7 comments
814 views