You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Hess <gh...@wrappedapps.com> on 2002/08/14 20:36:47 UTC

Cannot specify multiple log files with CommonsLogging/Log4j

Hi All,

I am deploying multiple instances of the same web app in the same web
container Resin2.1.2. I would like to have each web application use a unique
log file to simplify bug tracking. I am specifying the
log4j.appender.rolling.File=logs/appinstance1701794474_65.log with a new log
file for each deployed app.

I had expected when each new app is initialized it would initialize its
logging implementation through Commons.logging and

private static final Log m_log = LogFactory.getLog(SQLManager.class);

Would return the logging implementation for this web app. What happens is
that I receive a org.apache.commons.logging.Log but it uses the log file of
the first initialized web app.

I didn't think this was possible as each web app runs in its own VM and
LogFactory.getLog(SQLManager.class) could only return instantiated Log
implementation for the given web app.

Does anyone know why this is happening?

Thanks for your time,

Greg

RE: Cannot specify multiple log files with CommonsLogging/Log4j

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

On Thu, 15 Aug 2002, Greg Hess wrote:

> Date: Thu, 15 Aug 2002 09:25:37 -0400
> From: Greg Hess <gh...@wrappedapps.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: RE: Cannot specify multiple log files with CommonsLogging/Log4j
>
> Thanks, very interesting.
>
> Does this mean that I will have similar issues with my PoolManager or does
> it not use a static class reference(like Singleton)?
>
> Will all my Singleton's be shared between webapps?
>

It all depends on where you load the class from.

Singletones defined by classes loaded from /WEB-INF/classes or
/WEB-INF/lib are *not* shared across webapps.

Singletons defined by classes loaded from anywhere else (such as Tomcat's
$CATALINA_HOME/common/lib directory) are generally shared across webapps,
but the details depend greatly on the class loader architecture of your
particular container.  For Tomcat, you can find out more in the Tomcat
docs (depending on which version you are using):

http://jakarata.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html

http://jakarata.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html


> Thanks for your time,
>
> Greg

Craig


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


RE: Cannot specify multiple log files with CommonsLogging/Log4j

Posted by Greg Hess <gh...@wrappedapps.com>.
Thanks, very interesting.

Does this mean that I will have similar issues with my PoolManager or does
it not use a static class reference(like Singleton)?

Will all my Singleton's be shared between webapps?

Thanks for your time,

Greg

-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Wednesday, August 14, 2002 3:06 PM
To: Struts Users Mailing List
Subject: Re: Cannot specify multiple log files with CommonsLogging/Log4j




On Wed, 14 Aug 2002, Greg Hess wrote:

> Date: Wed, 14 Aug 2002 14:36:47 -0400
> From: Greg Hess <gh...@wrappedapps.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Mail List <st...@jakarta.apache.org>
> Subject: Cannot specify multiple log files with CommonsLogging/Log4j
>
> Hi All,
>
> I am deploying multiple instances of the same web app in the same web
> container Resin2.1.2. I would like to have each web application use a
unique
> log file to simplify bug tracking. I am specifying the
> log4j.appender.rolling.File=logs/appinstance1701794474_65.log with a new
log
> file for each deployed app.
>
> I had expected when each new app is initialized it would initialize its
> logging implementation through Commons.logging and
>
> private static final Log m_log = LogFactory.getLog(SQLManager.class);
>
> Would return the logging implementation for this web app. What happens is
> that I receive a org.apache.commons.logging.Log but it uses the log file
of
> the first initialized web app.
>
> I didn't think this was possible as each web app runs in its own VM and
> LogFactory.getLog(SQLManager.class) could only return instantiated Log
> implementation for the given web app.
>

Does Resin really do that (VM per webapp)?  That would be pretty
surprising.

On Tomcat, or other containers that use a single VM for all webapps, you
can accomplish what you are after by putting commons-logging.jar, Log4J,
and all of your classes inside the webapp, instead of in a shared
directory.  Then, "static" variables are per-webpp instead of global.

> Does anyone know why this is happening?
>
> Thanks for your time,
>
> Greg
>

Craig



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


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


Re: Cannot specify multiple log files with CommonsLogging/Log4j

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

On Wed, 14 Aug 2002, Greg Hess wrote:

> Date: Wed, 14 Aug 2002 14:36:47 -0400
> From: Greg Hess <gh...@wrappedapps.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Mail List <st...@jakarta.apache.org>
> Subject: Cannot specify multiple log files with CommonsLogging/Log4j
>
> Hi All,
>
> I am deploying multiple instances of the same web app in the same web
> container Resin2.1.2. I would like to have each web application use a unique
> log file to simplify bug tracking. I am specifying the
> log4j.appender.rolling.File=logs/appinstance1701794474_65.log with a new log
> file for each deployed app.
>
> I had expected when each new app is initialized it would initialize its
> logging implementation through Commons.logging and
>
> private static final Log m_log = LogFactory.getLog(SQLManager.class);
>
> Would return the logging implementation for this web app. What happens is
> that I receive a org.apache.commons.logging.Log but it uses the log file of
> the first initialized web app.
>
> I didn't think this was possible as each web app runs in its own VM and
> LogFactory.getLog(SQLManager.class) could only return instantiated Log
> implementation for the given web app.
>

Does Resin really do that (VM per webapp)?  That would be pretty
surprising.

On Tomcat, or other containers that use a single VM for all webapps, you
can accomplish what you are after by putting commons-logging.jar, Log4J,
and all of your classes inside the webapp, instead of in a shared
directory.  Then, "static" variables are per-webpp instead of global.

> Does anyone know why this is happening?
>
> Thanks for your time,
>
> Greg
>

Craig



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