You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Maxime Colas des Francs <ma...@hotmail.com> on 2002/10/02 14:51:35 UTC

log4j & tomcat

Hi,

I want to use log4j in a tomcat 4.1.10 web application.
and I think I don't understand relation between tomcat and log4j.

I have a log4j-1.2.6.jar

If i don't put it anywhere i have a :
    java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
in my 'onload' servlet (so i think it's nomal and i think log4j is not
integrate in tomcat)

If i put this jar in $CATALINA_HOME/common/lib,
it seems that tomcat and mod_jk2 libs use it and log in my application log
?!?
(and not a little ...)
DEBUG 2002-10-02 08:40:00,326 [main]
org.apache.jk.server.JkMain.processProperty(JkMain.java:468) : Processing
handler::handler list
DEBUG 2002-10-02 08:40:00,359 [main]
org.apache.jk.server.JkMain.processProperty(JkMain.java:468) : Processing
apr::apr NativeSo
DEBUG 2002-10-02 08:40:00,367 [main]
org.apache.jk.server.JkMain.processProperty(JkMain.java:481) : Setting
NativeSo on apr org.apache.jk.apr.AprImpl@26dbec
DEBUG 2002-10-02 08:40:00,371 [main]
org.apache.jk.server.JkMain.setBeanProperty(JkMain.java:359) : setProperty
org.apache.jk.apr.AprImpl@26dbec
... etc ...

If i put it in $CATALINA_HOME/webapps/myapp/WEB-INF/lib,
only my application log in my log file as expected.

Do you know why ??
Can i put it in common/lib and tell tomcat to stop log in my application log
?

Thanks.

My log configuration :

log4j.rootCategory=DEBUG,  textFile
log4j.appender.textFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.textFile.layout=org.apache.log4j.PatternLayout
log4j.appender.textFile.layout.ConversionPattern=%-5p %d [%t] %l : %m%n
log4j.appender.textFile.DatePattern='.'yyyy-MM-dd
log4j.appender.textFile.File=/usr/local/tomcat/webapps/myapp/logs/log.txt


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


Re: log4j & tomcat

Posted by Dan Lipofsky <da...@nuserve.com>.
This solution involves writing more code and
puts the burden on log4j.  I would prefer the
solution of simply telling tomcat not to use log4j
for its internal logging.  Is this possible?  Since
tomcat is capable of using different loggers and
has some mechanism to choose which one it uses,
how much harder would it be to give the user a bit
of control on that.  I would think it would already exist.
- Dan

> You are going to have to Buy Ceki Gülcü's book and look at the section
> about Repository Selectors.  Since log4j's configuration is static,
> the first app that configures log4j will have configured it for all
> contexts which is almost certainly not what you want.  You want your
> config file to be specific for your app.  That is where Repository
> Selectors come in.  I haven't read much about them, so I can't go into
> detail, but Ceki's book should answer just about any question you may
> have on Log4j.
>
> Actually, I spoke too quickly.  Look at this excerp from the book....
>
> http://qos.ch/containers/sc.html
>
> See about the book here:
> http://qos.ch/log4jBook.html



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


Re[2]: log4j & tomcat

Posted by Jacob Kjome <ho...@visi.com>.
Hello Dan,

You are going to have to Buy Ceki Gülcü's book and look at the section
about Repository Selectors.  Since log4j's configuration is static,
the first app that configures log4j will have configured it for all
contexts which is almost certainly not what you want.  You want your
config file to be specific for your app.  That is where Repository
Selectors come in.  I haven't read much about them, so I can't go into
detail, but Ceki's book should answer just about any question you may
have on Log4j.

Actually, I spoke too quickly.  Look at this excerp from the book....

http://qos.ch/containers/sc.html

See about the book here:
http://qos.ch/log4jBook.html

Jake

Wednesday, October 02, 2002, 11:22:31 AM, you wrote:

DL> Is there a way to control this?
DL> Suppose I do want to put log4j.jar in common/lib (because I
DL> don't want to wrap it in the war and reinstall it every time).
DL> But I want it only to be used by my application.
DL> Can I do this?
DL> - Dan

>> There's a library called common-lib that uses any of log systems you have.
>> Modjk2 uses it, so if you put log4j in common/lib modjk2 will use it. If
DL> you
>> put modjk2 it in your webbapps directory, then only your application can
>> reach it.
>>
>> Regards
>>
>> -----Mensaje original-----
>> De: Maxime Colas des Francs [mailto:max_sts@hotmail.com]
>> Enviado el: miércoles, 02 de octubre de 2002 14:52
>> Para: Tomcat Users List
>> Asunto: log4j & tomcat
>>
>> Hi,
>>
>> I want to use log4j in a tomcat 4.1.10 web application.
>> and I think I don't understand relation between tomcat and log4j.
>>
>> I have a log4j-1.2.6.jar
>>
>> If i don't put it anywhere i have a :
>>     java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
>> in my 'onload' servlet (so i think it's nomal and i think log4j is not
>> integrate in tomcat)
>>
>> If i put this jar in $CATALINA_HOME/common/lib,
>> it seems that tomcat and mod_jk2 libs use it and log in my application log
>> ?!?
>> (and not a little ...)
>> DEBUG 2002-10-02 08:40:00,326 [main]
>> org.apache.jk.server.JkMain.processProperty(JkMain.java:468) : Processing
>> handler::handler list
>> DEBUG 2002-10-02 08:40:00,359 [main]
>> org.apache.jk.server.JkMain.processProperty(JkMain.java:468) : Processing
>> apr::apr NativeSo
>> DEBUG 2002-10-02 08:40:00,367 [main]
>> org.apache.jk.server.JkMain.processProperty(JkMain.java:481) : Setting
>> NativeSo on apr org.apache.jk.apr.AprImpl@26dbec
>> DEBUG 2002-10-02 08:40:00,371 [main]
>> org.apache.jk.server.JkMain.setBeanProperty(JkMain.java:359) : setProperty
>> org.apache.jk.apr.AprImpl@26dbec
>> ... etc ...
>>
>> If i put it in $CATALINA_HOME/webapps/myapp/WEB-INF/lib,
>> only my application log in my log file as expected.
>>
>> Do you know why ??
>> Can i put it in common/lib and tell tomcat to stop log in my application
DL> log
>> ?
>>
>> Thanks.
>>
>> My log configuration :
>>
>> log4j.rootCategory=DEBUG,  textFile
>> log4j.appender.textFile=org.apache.log4j.DailyRollingFileAppender
>> log4j.appender.textFile.layout=org.apache.log4j.PatternLayout
>> log4j.appender.textFile.layout.ConversionPattern=%-5p %d [%t] %l : %m%n
>> log4j.appender.textFile.DatePattern='.'yyyy-MM-dd
>> log4j.appender.textFile.File=/usr/local/tomcat/webapps/myapp/logs/log.txt



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



-- 
Best regards,
 Jacob                            mailto:hoju@visi.com


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


Re: log4j & tomcat

Posted by Dan Lipofsky <da...@nuserve.com>.
Is there a way to control this?
Suppose I do want to put log4j.jar in common/lib (because I
don't want to wrap it in the war and reinstall it every time).
But I want it only to be used by my application.
Can I do this?
- Dan

> There's a library called common-lib that uses any of log systems you have.
> Modjk2 uses it, so if you put log4j in common/lib modjk2 will use it. If
you
> put modjk2 it in your webbapps directory, then only your application can
> reach it.
>
> Regards
>
> -----Mensaje original-----
> De: Maxime Colas des Francs [mailto:max_sts@hotmail.com]
> Enviado el: miércoles, 02 de octubre de 2002 14:52
> Para: Tomcat Users List
> Asunto: log4j & tomcat
>
> Hi,
>
> I want to use log4j in a tomcat 4.1.10 web application.
> and I think I don't understand relation between tomcat and log4j.
>
> I have a log4j-1.2.6.jar
>
> If i don't put it anywhere i have a :
>     java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
> in my 'onload' servlet (so i think it's nomal and i think log4j is not
> integrate in tomcat)
>
> If i put this jar in $CATALINA_HOME/common/lib,
> it seems that tomcat and mod_jk2 libs use it and log in my application log
> ?!?
> (and not a little ...)
> DEBUG 2002-10-02 08:40:00,326 [main]
> org.apache.jk.server.JkMain.processProperty(JkMain.java:468) : Processing
> handler::handler list
> DEBUG 2002-10-02 08:40:00,359 [main]
> org.apache.jk.server.JkMain.processProperty(JkMain.java:468) : Processing
> apr::apr NativeSo
> DEBUG 2002-10-02 08:40:00,367 [main]
> org.apache.jk.server.JkMain.processProperty(JkMain.java:481) : Setting
> NativeSo on apr org.apache.jk.apr.AprImpl@26dbec
> DEBUG 2002-10-02 08:40:00,371 [main]
> org.apache.jk.server.JkMain.setBeanProperty(JkMain.java:359) : setProperty
> org.apache.jk.apr.AprImpl@26dbec
> ... etc ...
>
> If i put it in $CATALINA_HOME/webapps/myapp/WEB-INF/lib,
> only my application log in my log file as expected.
>
> Do you know why ??
> Can i put it in common/lib and tell tomcat to stop log in my application
log
> ?
>
> Thanks.
>
> My log configuration :
>
> log4j.rootCategory=DEBUG,  textFile
> log4j.appender.textFile=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.textFile.layout=org.apache.log4j.PatternLayout
> log4j.appender.textFile.layout.ConversionPattern=%-5p %d [%t] %l : %m%n
> log4j.appender.textFile.DatePattern='.'yyyy-MM-dd
> log4j.appender.textFile.File=/usr/local/tomcat/webapps/myapp/logs/log.txt



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


RE: log4j & tomcat

Posted by Miguel Angel Mulero Martinez <mi...@mad.tecsidel.es>.
There's a library called common-lib that uses any of log systems you have.
Modjk2 uses it, so if you put log4j in common/lib modjk2 will use it. If you
put modjk2 it in your webbapps directory, then only your application can
reach it.

Regards

-----Mensaje original-----
De: Maxime Colas des Francs [mailto:max_sts@hotmail.com]
Enviado el: miércoles, 02 de octubre de 2002 14:52
Para: Tomcat Users List
Asunto: log4j & tomcat

Hi,

I want to use log4j in a tomcat 4.1.10 web application.
and I think I don't understand relation between tomcat and log4j.

I have a log4j-1.2.6.jar

If i don't put it anywhere i have a :
    java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
in my 'onload' servlet (so i think it's nomal and i think log4j is not
integrate in tomcat)

If i put this jar in $CATALINA_HOME/common/lib,
it seems that tomcat and mod_jk2 libs use it and log in my application log
?!?
(and not a little ...)
DEBUG 2002-10-02 08:40:00,326 [main]
org.apache.jk.server.JkMain.processProperty(JkMain.java:468) : Processing
handler::handler list
DEBUG 2002-10-02 08:40:00,359 [main]
org.apache.jk.server.JkMain.processProperty(JkMain.java:468) : Processing
apr::apr NativeSo
DEBUG 2002-10-02 08:40:00,367 [main]
org.apache.jk.server.JkMain.processProperty(JkMain.java:481) : Setting
NativeSo on apr org.apache.jk.apr.AprImpl@26dbec
DEBUG 2002-10-02 08:40:00,371 [main]
org.apache.jk.server.JkMain.setBeanProperty(JkMain.java:359) : setProperty
org.apache.jk.apr.AprImpl@26dbec
... etc ...

If i put it in $CATALINA_HOME/webapps/myapp/WEB-INF/lib,
only my application log in my log file as expected.

Do you know why ??
Can i put it in common/lib and tell tomcat to stop log in my application log
?

Thanks.

My log configuration :

log4j.rootCategory=DEBUG,  textFile
log4j.appender.textFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.textFile.layout=org.apache.log4j.PatternLayout
log4j.appender.textFile.layout.ConversionPattern=%-5p %d [%t] %l : %m%n
log4j.appender.textFile.DatePattern='.'yyyy-MM-dd
log4j.appender.textFile.File=/usr/local/tomcat/webapps/myapp/logs/log.txt


--
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>