• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Logger.getLogger()

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

can you tell me " Logger.getLogger(DBUtil.class.getName())" what this does ?
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing to do with Servlets. Moved to a more appropriate location.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It'd be helpful if you stated which logging package you're using. But in a nutshell it creates a logger for the specified class.
 
jazy smith
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@david: Can you please explain in few lines. I tried to go through the javadocs for class.getName(). It returns the string. now here DBUtil is my class. so, that makes DBUtil.some_string_returnedby_class.getName(). Are you getting me what am I pointing towards and what is my doubt ?
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you made your question more unclear by that post. Is your question "What does the getName() method of a class object return?" If so, and if the API documentation is unclear to you, then you could find that out by a small test program containing one line of executable code.
 
jazy smith
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Paul: thanks dude. It worked for me !
 
jazy smith
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
guys,

this is interesting. (1) Logger.getLogger("Database.class.getName()");

(2) Logger.getLogger("Database.getName()");

(3) Logger.getLogger("hi.getName()");

(4) Logger.getLogger("hello.getName()");

(5) Logger.getLogger("getName()");


where Database is a java file. and hi and hello are nothing. ( just random words ) all above 5 cases give the same output. Why ? can anyone explain it to me ?

another Sequence. (1) Logger.getLogger(Database.class.getName()); --> works.

(2) Logger.getLogger(Database.getName()); --> doesn't work

(3) Logger.getLogger(getName()); --> doesn't work either

why is it so ??
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Because you're passing in a string which is meaningless to the logging system.
2) Probably because you're not matching the method signature of getLogger(), but since you don't indicate what the symptoms are, it's impossible to say much more. And I still don't know what logging system you're using.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would be helpful to check doc on apache as following:
http://logging.apache.org/log4j/1.2/apidocs/index.html

it is obverisly nothing to do with serlet.

You can use Class as a pramater or use String as a pramater, both are the same.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic