You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Koen Jans <ko...@student.kuleuven.be> on 2005/10/22 16:46:06 UTC

Where to put logstatements?

I'm using log4j, but i cannot decide where to place the log-statements.. 
For instance when a user adds an account.

My options are: 
- in the ActionClasses. (This seems to be the common approach, but then
there's logstatements in the "Controller" part, which seems not that
logic to me). So here the logstatement would be in the AddAccountAction
class.
- in the BusinessLogic. So here the log-statement would be in the
AccountHandler.addAccount(..) method or something.

Where do you put your logstatements, and why do you put them in the
actionclasses (if you do so:) )?

Thanks for your time,
koen




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Where to put logstatements?

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
I put log statements any place there is something I want to log :) 
Seriously, it sounds like a wise-ass answer, but it isn't.

Logging is a cross-cutting concern, and as such doesn't really apply to 
any one part of a system.  I personally like to have at least one debug 
or trace level log message in every method of my application, even if 
it's just a "methodA() starting".  This makes it easier to trace the 
execution flow of the application when developing or debugging.

You may have missed it, but Ted Husted recently posted a link to an 
interesting article:

http://www-128.ibm.com/developerworks/java/library/j-sr2.html

Near the end they talk about using Spring interceptors to deal with 
cross-cutting concerning, logging being the specific example.  Might 
apply for you, and it's an interesting article none the less if you've 
ever considered Spring.

But, that aside, I would say putting logging anywhere there is something 
you think you'd want to see in a log, don't even think about where it 
falls in the high-level architecture.

Frank

Koen Jans wrote:
> I'm using log4j, but i cannot decide where to place the log-statements.. 
> For instance when a user adds an account.
> 
> My options are: 
> - in the ActionClasses. (This seems to be the common approach, but then
> there's logstatements in the "Controller" part, which seems not that
> logic to me). So here the logstatement would be in the AddAccountAction
> class.
> - in the BusinessLogic. So here the log-statement would be in the
> AccountHandler.addAccount(..) method or something.
> 
> Where do you put your logstatements, and why do you put them in the
> actionclasses (if you do so:) )?
> 
> Thanks for your time,
> koen
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> .
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org