You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Qiqi Dong <qd...@swbell.net> on 2001/02/17 21:51:50 UTC

Use log4j with struts

I want to use log4j with Struts/Tomcat and like all servlets in a webapp to have same priority and log file. ALso, the priority and log file should be set and changed with servlet's initial parameters. Any idea from where should I start? Also, anyone has examples to use different hierarchy for multi virtual hosts?

Re: Use log4j with struts

Posted by Qiqi Dong <qd...@swbell.net>.
John,

Thanks for responding.

Where is the right place to initialize the log4j system, e.g. to call
Configurator? I'd like to install a FileAppender and WARN Priority at the
root, and let each servlet, ActionServlet,  override them if specified in
its initParameters. All Action and other classes registered with the servlet
should share same Appender and Priority. Should the root catagory be set at
the container startup? The sevlet init() seems the right place for
overriding the root. But I don't want to change either Tomcat or Struts
codes. Also, it probably mean I have to use some naming writing Actions.

Any suggestions?

Qiqi


----- Original Message -----
From: "John Carnahan" <ca...@protos.lifesci.ucla.edu>
To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
Sent: Sunday, February 18, 2001 11:35 AM
Subject: Re: Use log4j with struts


> Qiqi,
>
> The servlet side is pretty easy - as you likely already know. Use
> Servlet.getServletConfig().getServletContext().getInitParameter("foo").
> Then within the web-app config use <context-param foo='bar'/>. Then just
> initialize the log4j system at runtime. In this way you can use a
> different hierarchy for different virtual hosts. The problem here, of
> course, is that this would likely have to done on every run because
> servlet instances can be shared across web-apps and thus member
> variables would be a bad place to stuff cached config info. I have never
> tried it but this method should work although pretty inefficient.
>
> John
>
>
>
>
> Qiqi Dong wrote:
>
> > I want to use log4j with Struts/Tomcat and like all servlets in a
> > webapp to have same priority and log file. ALso, the priority and log
> > file should be set and changed with servlet's initial parameters. Any
> > idea from where should I start? Also, anyone has examples to use
> > different hierarchy for multi virtual hosts?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>


Re: Use log4j with struts

Posted by John Carnahan <ca...@protos.lifesci.ucla.edu>.
Qiqi,

The servlet side is pretty easy - as you likely already know. Use
Servlet.getServletConfig().getServletContext().getInitParameter("foo").
Then within the web-app config use <context-param foo='bar'/>. Then just
initialize the log4j system at runtime. In this way you can use a
different hierarchy for different virtual hosts. The problem here, of
course, is that this would likely have to done on every run because
servlet instances can be shared across web-apps and thus member
variables would be a bad place to stuff cached config info. I have never
tried it but this method should work although pretty inefficient.

John




Qiqi Dong wrote:

> I want to use log4j with Struts/Tomcat and like all servlets in a
> webapp to have same priority and log file. ALso, the priority and log
> file should be set and changed with servlet's initial parameters. Any
> idea from where should I start? Also, anyone has examples to use
> different hierarchy for multi virtual hosts?