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 Ivan Aguirre <iv...@yahoo.com.br> on 2004/07/29 18:22:24 UTC
Where's the Tomcat log messages?
Hi
I'm using Tomcat 5.0.18 and I would like to customize the Log4J messages on the packages of a Webapp.
Well, I created a file Log4J.XML and it's the Classpath. The file has been loading correctly and the log messages from my Webapp classes are going fine.
The problem is that the messages from Tomcat, like one's on startup or when reloading a Context don't happen anymore.
There's a copy of the file below.
Does anyone knows why ?
Thankx
-----------------------------------
Ivan de Aguirre
Java Developer
CpQD - www.cpqd.com.br
Log4J.XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="target" value="System.err" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p [%c] %m%n" />
</layout>
</appender>
<logger name="br.com.cpqd.www.sam" additivity="false">
<level value="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger>
<root>
<priority value="WARN" />
<appender-ref ref="CONSOLE" />
</root>
</log4j:configuration>
---------------------------------
Yahoo! Mail agora ainda melhor: 100MB, anti-spam e antivírus grátis!
Re: Where's the Tomcat log messages?
Posted by Jacob Kjome <ho...@visi.com>.
Quoting Ivan Aguirre <iv...@yahoo.com.br>:
> There's a Log4j1.2.8..jar on directories:
>
> CATALINA_HOME/common/classes (1)
You mean CATALINA_HOME/common/lib, right?
> and
> WEB-INF/lib (2)
>
> There's a file Log4J.XML only on:
> WEB-INF/classes/..../etc (3)
>
You mean directly in the directory WEB-INF/classes, not some subpackage, right?
> And I setup the classpath to look to (3), so I think this should be the
> reason why it picks the webapp Log4J.XML.
>
Huh? You set up the system classpath for this? There are two reasons not to do
that.
1. Your webapp path is more dynamic than the CLASSPATH variable. If you
changed your webapp context name, the path could change. You might even install
Tomcat somewhere else, or upgrade versions, making the path invalid.
2. Tomcat, itself, ignores your CLASSPATH variable unless you modify the
startup scripts to pay attention to it.
3. If Tomcat did not ingore your CLASSPATH variable and you put WEB-INF/classes
of your application into the CLASSPATH, your classes will no longer be
reloadable upon application restart because they would be loaded in the same
classloader as Tomcat is in rather than a child loader which could be dumped.
4. Another result of #3 is that commons-logging would see the log4j.xml from
the webapp, resulting in the default logger repository (which Tomcat would be
using) using your webapp's logging config rather than some other config.
Now, similar to #4, commons-logging uses classloading tricks to "discover" Log4j
and config files. This means it may very well find log4j.xml in WEB-INF/classes
rather than not being able to see it, which would be the normal case. To
prevent this, if you have log4j.jar in common/lib, you should put a log4j.xml
file in common/classes which provides logging configuration for Tomcat. And
then make sure you keep putting log4j.jar in WEB-INF/lib and the app's config
file in WEB-INF/classes.
> More questions arise:
>
> 1. If If move Log4J.XML from (3) to WEB-INF/class the Tomcat log works
> normal, but not the webaap log's, it's seems it can't find the file.
>
> 2. Even if it's using the WebApp Log4J.XML from my webapp, in this I set the
> root level to WARN, so why no messages on Tomcat Log ?
>
Please see what I wrote above and if you are still having problems, take a look
at the Tomcat FAQ which addresses configuring Log4j in Tomcat.
Jake
> Jacob Kjome <ho...@visi.com> wrote:
> Where did you put the log4j.xml file? Is it in WEB-INF/classes or is it
> somewhere like CATALINA_HOME/common/classes? If the latter and log4j.jar
> is in common/lib, then this is exactly the behavior one would expect. Make
> sure you put log4j.xml in WEB-INF/classes and log4j.jar in WEB-INF/lib of
> each and every webapp.
>
> Jake
>
> At 01:22 PM 7/29/2004 -0300, you wrote:
> >Hi
> >
> >I'm using Tomcat 5.0.18 and I would like to customize the Log4J messages
> >on the packages of a Webapp.
> >
> >Well, I created a file Log4J.XML and it's the Classpath. The file has been
> >loading correctly and the log messages from my Webapp classes are going
> fine.
> >
> >The problem is that the messages from Tomcat, like one's on startup or
> >when reloading a Context don't happen anymore.
> >
> >There's a copy of the file below.
> >
> >Does anyone knows why ?
> >
> >Thankx
> >
> >-----------------------------------
> >Ivan de Aguirre
> >Java Developer
> >CpQD - www.cpqd.com.br
> >
> >
> >Log4J.XML
> >
> >
> >
> >
> >
> >
> >
>
> >
> >
>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
> >
> >
> >
> >
> >
> >
> >---------------------------------
> >Yahoo! Mail agora ainda melhor: 100MB, anti-spam e antivírus grátis!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>
> ---------------------------------
> Yahoo! Mail agora ainda melhor: 100MB, anti-spam e antivírus grátis!
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Where's the Tomcat log messages?
Posted by Ivan Aguirre <iv...@yahoo.com.br>.
There's a Log4j1.2.8..jar on directories:
CATALINA_HOME/common/classes (1)
and
WEB-INF/lib (2)
There's a file Log4J.XML only on:
WEB-INF/classes/..../etc (3)
And I setup the classpath to look to (3), so I think this should be the reason why it picks the webapp Log4J.XML.
More questions arise:
1. If If move Log4J.XML from (3) to WEB-INF/class the Tomcat log works normal, but not the webaap log's, it's seems it can't find the file.
2. Even if it's using the WebApp Log4J.XML from my webapp, in this I set the root level to WARN, so why no messages on Tomcat Log ?
Jacob Kjome <ho...@visi.com> wrote:
Where did you put the log4j.xml file? Is it in WEB-INF/classes or is it
somewhere like CATALINA_HOME/common/classes? If the latter and log4j.jar
is in common/lib, then this is exactly the behavior one would expect. Make
sure you put log4j.xml in WEB-INF/classes and log4j.jar in WEB-INF/lib of
each and every webapp.
Jake
At 01:22 PM 7/29/2004 -0300, you wrote:
>Hi
>
>I'm using Tomcat 5.0.18 and I would like to customize the Log4J messages
>on the packages of a Webapp.
>
>Well, I created a file Log4J.XML and it's the Classpath. The file has been
>loading correctly and the log messages from my Webapp classes are going fine.
>
>The problem is that the messages from Tomcat, like one's on startup or
>when reloading a Context don't happen anymore.
>
>There's a copy of the file below.
>
>Does anyone knows why ?
>
>Thankx
>
>-----------------------------------
>Ivan de Aguirre
>Java Developer
>CpQD - www.cpqd.com.br
>
>
>Log4J.XML
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>---------------------------------
>Yahoo! Mail agora ainda melhor: 100MB, anti-spam e antivírus grátis!
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
---------------------------------
Yahoo! Mail agora ainda melhor: 100MB, anti-spam e antivírus grátis!
Re: Where's the Tomcat log messages?
Posted by Jacob Kjome <ho...@visi.com>.
Where did you put the log4j.xml file? Is it in WEB-INF/classes or is it
somewhere like CATALINA_HOME/common/classes? If the latter and log4j.jar
is in common/lib, then this is exactly the behavior one would expect. Make
sure you put log4j.xml in WEB-INF/classes and log4j.jar in WEB-INF/lib of
each and every webapp.
Jake
At 01:22 PM 7/29/2004 -0300, you wrote:
>Hi
>
>I'm using Tomcat 5.0.18 and I would like to customize the Log4J messages
>on the packages of a Webapp.
>
>Well, I created a file Log4J.XML and it's the Classpath. The file has been
>loading correctly and the log messages from my Webapp classes are going fine.
>
>The problem is that the messages from Tomcat, like one's on startup or
>when reloading a Context don't happen anymore.
>
>There's a copy of the file below.
>
>Does anyone knows why ?
>
>Thankx
>
>-----------------------------------
>Ivan de Aguirre
>Java Developer
>CpQD - www.cpqd.com.br
>
>
>Log4J.XML
>
><?xml version="1.0" encoding="ISO-8859-1"?>
><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
><log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
>
> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
> <param name="target" value="System.err" />
> <layout class="org.apache.log4j.PatternLayout">
> <param name="ConversionPattern" value="%-5p [%c] %m%n" />
> </layout>
> </appender>
>
> <logger name="br.com.cpqd.www.sam" additivity="false">
> <level value="DEBUG" />
> <appender-ref ref="CONSOLE" />
> </logger>
>
> <root>
> <priority value="WARN" />
> <appender-ref ref="CONSOLE" />
> </root>
></log4j:configuration>
>
>
>
>---------------------------------
>Yahoo! Mail agora ainda melhor: 100MB, anti-spam e antivírus grátis!
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org