Meaningless Drivel is fun!
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

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
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

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 ?


Vince Hon<br /> <br />SCJP 1.4 | SCWCD | SCBCD <br /><a href="" target="_blank" rel="nofollow"></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

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:
subject: Good logging system for WebApp (Struts)
It's not a secret anymore!