File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Good logging system for WebApp (Struts) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Good logging system for WebApp (Struts)" Watch "Good logging system for WebApp (Struts)" New topic
Author

Good logging system for WebApp (Struts)

Vince Hon
Ranch Hand

Joined: Feb 11, 2003
Posts: 117
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<br /> <br />SCJP 1.4 | SCWCD | SCBCD <br /><a href="http://vincehon.homeip.net:8000/VJW" target="_blank" rel="nofollow">http://vincehon.homeip.net:8000/VJW</a>
Vince Hon
Ranch Hand

Joined: Feb 11, 2003
Posts: 117
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

Joined: Jul 18, 2005
Posts: 29
Hey Vince, why don't you use a Filter?
That, and with Log4j will let you do about anything ya need.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Good logging system for WebApp (Struts)