You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Oded Arbel <od...@geek.co.il> on 2006/02/09 15:23:47 UTC

Log4j configuration on a per context basis

Guys, how can I setup log4j with a context specific configuration file ? 

In the past I used to put a global log4j configuration in the system 
classpath for the tomcat, but that is no longer appropriate in my 
current setup.

-- 
Oded

::..
"Who the hell wants to hear actors talk?"
	-- H. M. Warner (1881-1958), founder of Warner Brothers, in 1927

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Log4j configuration on a per context basis

Posted by Jess Holle <je...@ptc.com>.
This is trivial if you only introduce log4j.jar in each web app.

If you share log4j.jar across web apps, then you have some 
LoggerRepositorySelector coding ahead of you.  This is easy enough via 
JNDI context for cases where the contextual classloader is set for you 
by Tomcat, but in other cases (e.g. JMX remote request threads) you 
have  to do such classloader setup yourself.

Our web app now supports a per context log4j even if log4j.jar is shared 
-- in which case anything outside all the web apps goes into another 
log4j context.

Note the log4j JMX MBeans don't support this sort of thing properly 
(they have a hard-wired ObjectName location for starters), so you'll 
have to write your own if you're interested in that aspect.

Oded Arbel wrote:
> Guys, how can I setup log4j with a context specific configuration file ? 
>
> In the past I used to put a global log4j configuration in the system 
> classpath for the tomcat, but that is no longer appropriate in my 
> current setup.
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Log4j configuration on a per context basis

Posted by Oded Arbel <od...@geek.co.il>.
On Thursday, 9 בFebruary 2006 16:30, Boris Unckel wrote:
> > Guys, how can I setup log4j with a context specific configuration
> > file ?
> >
> > In the past I used to put a global log4j configuration in the
> > system classpath for the tomcat, but that is no longer appropriate
> > in my current setup.
>
> Hi,
>
> remove any log4j.jar and log4j.properties from your global
> classpathes (system classpath, common, shared).
> Put a log4j.jar and log4j.properties in each WEB-INF/lib (jar) and
> WEB-INF/classes (properties) with the correspondent config.

Thanks.

I figured that something like that would work, but for some non-related 
issues, I rather not have a classes directory. Is there a way to have a 
log4j configuration available to the web app w/o putting it in the 
classes dir or in a jar file ? maybe someway to setup the context.xml 
to point to a log4j configuration directly in WEB-INF ?

-- 
Oded

::..
The essential ideas of Algol 68 were that the whole language should be 
precisely defined and that all the pieces should fit together smoothly. 
The basic idea behind Pascal was that it didn't matter how vague the 
language specification was (it took *years* to clarify) or how many 
rough edges there were, as long as the CDC Pascal compiler was fast.
	-- Richard A. O'Keefe

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Log4j configuration on a per context basis

Posted by Boris Unckel <bo...@gmx.net>.
> Guys, how can I setup log4j with a context specific configuration file ? 
> 
> In the past I used to put a global log4j configuration in the system 
> classpath for the tomcat, but that is no longer appropriate in my 
> current setup.
> 
Hi,

remove any log4j.jar and log4j.properties from your global classpathes
(system classpath, common, shared).
Put a log4j.jar and log4j.properties in each WEB-INF/lib (jar) and
WEB-INF/classes (properties) with the correspondent config.

Regards
Boris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org