You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Oleg V Alexeev <oa...@apache.org> on 2002/03/05 08:43:15 UTC

Logger in ActionServlet

Hello Struts,

  Log variable in ActionServlet is private and get method to obtain it
  not exist - is it a part of some ideology or a partial solution?

  So what is the best way to use commons-logging - use one logger
  instance from base class (so make log in ActionServlet protected and
  add get method for it) or retrieve logger instance for every class
  (so for extended version of the ActionServlet it would be another
  logger for another classname)?


-- 
Best regards,
 Oleg                          mailto:oalexeev@apache.org



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Logger in ActionServlet

Posted by David Winterfeldt <dw...@yahoo.com>.
I wasn't sure if it was good to encourage someone
using another classes logger because it might make the
logs harder to read and control.  So I didn't add
access for the logger.  And you do still have access
to the servlet log.

I agree with Craig.  I think it is good form to define
your own logger so you can control log levels and
loggers/appenders based package names.  It works out
very nicely.  You can have a master log, all
org.apache.struts go to another, and have your source
log one too (or whatever you want).

David

--- "Craig R. McClanahan" <cr...@apache.org> wrote:
> 
> 
> On Tue, 5 Mar 2002, Oleg V Alexeev wrote:
> 
> > Date: Tue, 5 Mar 2002 10:43:15 +0300
> > From: Oleg V Alexeev <oa...@apache.org>
> > Reply-To: Struts Developers List
> <st...@jakarta.apache.org>,
> >      Oleg V Alexeev <oa...@apache.org>
> > To: Struts Developers List
> <st...@jakarta.apache.org>
> > Subject: Logger in ActionServlet
> >
> > Hello Struts,
> >
> >   Log variable in ActionServlet is private and get
> method to obtain it
> >   not exist - is it a part of some ideology or a
> partial solution?
> >
> >   So what is the best way to use commons-logging -
> use one logger
> >   instance from base class (so make log in
> ActionServlet protected and
> >   add get method for it) or retrieve logger
> instance for every class
> >   (so for extended version of the ActionServlet it
> would be another
> >   logger for another classname)?
> >
> 
> Although I agree with you that the ActionServlet's
> notion of a Log
> instance should be available somehow (probably
> through a public getter
> method), my current preference has been to have a
> separate named Log
> instance per Struts sub-application.  That means
> that sub-apps (and, by
> extension of the same philosophy, add-on components)
> should define their
> own logger names.
> 
> One non-obvious facet of the SimpleLog
> implementation in commons-logging
> 1.0 (and, I *think*, in Log4J and JDK 1.4 logging as
> well) is that logging
> level setting is hierarchical -- if a level is not
> set for a particular
> logger name, then SimpleLog will start chopping off
> "." delimited
> components before it uses the default level. 
> Therefore, you can configure
> a logging level for "org.apache.struts" that applies
> to *all* loggers
> whose names start with this, unless they are
> explicity set to some other
> value.
> 
> >
> > --
> > Best regards,
> >  Oleg                         
> mailto:oalexeev@apache.org
> >
> 
> Craig
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Logger in ActionServlet

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 5 Mar 2002, Oleg V Alexeev wrote:

> Date: Tue, 5 Mar 2002 10:43:15 +0300
> From: Oleg V Alexeev <oa...@apache.org>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>,
>      Oleg V Alexeev <oa...@apache.org>
> To: Struts Developers List <st...@jakarta.apache.org>
> Subject: Logger in ActionServlet
>
> Hello Struts,
>
>   Log variable in ActionServlet is private and get method to obtain it
>   not exist - is it a part of some ideology or a partial solution?
>
>   So what is the best way to use commons-logging - use one logger
>   instance from base class (so make log in ActionServlet protected and
>   add get method for it) or retrieve logger instance for every class
>   (so for extended version of the ActionServlet it would be another
>   logger for another classname)?
>

Although I agree with you that the ActionServlet's notion of a Log
instance should be available somehow (probably through a public getter
method), my current preference has been to have a separate named Log
instance per Struts sub-application.  That means that sub-apps (and, by
extension of the same philosophy, add-on components) should define their
own logger names.

One non-obvious facet of the SimpleLog implementation in commons-logging
1.0 (and, I *think*, in Log4J and JDK 1.4 logging as well) is that logging
level setting is hierarchical -- if a level is not set for a particular
logger name, then SimpleLog will start chopping off "." delimited
components before it uses the default level.  Therefore, you can configure
a logging level for "org.apache.struts" that applies to *all* loggers
whose names start with this, unless they are explicity set to some other
value.

>
> --
> Best regards,
>  Oleg                          mailto:oalexeev@apache.org
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>