• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logging Design Confusion

 
nico dotti
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've finally got my webapp to do java.util.logging with Tomcat using the WEB-IN/classes/logging.properties that's required. Just to make sure things were working I've created Logger objects in a few of my app's objects (a Servlet, POJO, and a JSP) and successfully logged messages.

Now that I've got that working, I'm wondering how I should set it up so that I don't create Logger objects in each application object that needs logging! I'm not sure whether I can:
- use my Listener and set the Logger as an attribute (but then will it get GC'd when it's not referenced or does my Listener always have a reference?)
- should I create a Servlet that serves as the entry point into my app that creates a Logger in it's init() method? If so, do I pass the Logger instance along from one object to another?
- Singleton? How to implement?

I've been googl'ing for hours and I can't seem to figure this out I'm sure this is something that's been tackled countless times in the 'real world'. If someone knows of a preferred way to do this, why that way is preferred, and can provide some basic pseudocode I can follow I'd deeply appreciate it!
 
nico dotti
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, looks like setting it as an attribute works out fine
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic