Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Good logging system for WebApp (Struts)

 
Vince Hon
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question is that: How to get the Logger for my webapp ? I have designed 3 cases:

case 1:
Getting a private static logger of each classes. As there are many StrutsAction classes, it seems the code is not tidy.



case 2:
Write a single Logger common to the package, and ALL classes within the webapp will use this logger for logging.


case 3:
Same as case 2, except I initialize a Logger during the SerletContext Initialization and put this as ServletContext attribute, then all StrutsAction class get the logger from Servlet Context during runtime.



Thus, prevent from using a static logger which is hardcoded in the StrutsAction class. However, I doubt if any significant overhead is added in the system.


Could any expert share your experience about this ?

Thanks
 
Vince Hon
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
additional info of my webapp:

I am now designing a logging system for my webapp which is based on Apache Struts framework.

To avoid using System.out.println() for logging, I use the J2SE java.util.logging tools.
 
Yong Bakos
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Vince, why don't you use a Filter?
That, and with Log4j will let you do about anything ya need.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic