Hi,
Well you are one of those asking about logging. Don't get overly exited about
the logging detail I have added to the logging page. The kind of logging you
are attempting to do I believe you are confused about (i may be wrong). You are
setting up logging from *within* Tomcat. This will tell you very little about
your web application. If the type of logging you are referring to is the old
localhost_log style logging, this will be stdout you need. In any case, here is
the HTML.
<section name="Introduction">
<p>
Tomcat 5.5 uses Commons Logging throughout its internal code
allowing the developer to choose a logging configuration that
suits their needs, e.g
JDK Logging or log4j. Commons Logging provides Tomcat the
ability to log
hierarchially across various log levels without needing to rely
on a particular
logging implementation. Commons Logging is therefore a bridge
to other implementations.
<a href="http://jakarta.apache.org/commons/logging/">Visit the
Commons Logging project</a>
for more information.
</p>
<p>
An important consequence for Tomcat 5.5 is that the
<Logger> element found in
previous versions to create a localhost_log, is no longer a
valid nested element
of <Context>. Instead, stdout will collect runtime
exceptions and other uncaught
exception generated by web applications. If the developer
wishes to collect detailed internal
Tomcat logging (i.e what is happening within the Tomcat
engine), then they should configure
a logging system such as JDK Logging or log4j as detailed next.
</p>
<p>
One note to point out is that currently, the log4j
configuration will not function on
Tomcat server startup, so JDK Logging is more reliable at this
point. This is a known
issue in the pipeline for fix.
</p>
</section>
<section name="java.util.logging">
<p>
In order to configure JDK logging you should have JDK 1.4+.
Tomcat 5.5 is intended for
JDK 5.0, but can be run on JDK 1.4 using a compatibility
package.
</p>
<p>
In order to configure JDK Logging, you should find the JDK's
logging.properties file. Check
your JAVA_HOME environment setting to see which JDK Tomcat is
using (or maybe JRE 5.0 as Tomcat
can now run on a JRE from version 5.5). The file will be in
<i>${JAVA_HOME}/jre/lib</i>.
</p>
<p>
The default logging.properties specifies a ConsoleHandler for
routing logging to stdout and
also a FileHandler. A handler's log level threshold can be set
using SEVERE, CONFIG, INFO,
WARN, FINE, FINEST or ALL. The logging.properties shipped with
JDK is set to INFO. You
can also target specific packages to collect logging from and
specify a level. Here is how
you would set debugging from Tomcat. You would need to ensure
the ConsoleHandler's level is also
set to collect this threshold, so FINEST or ALL should be set.
</p>
<p><source>org.apache.catalina.level=FINEST</source></p>
<p>A limitation of JDK Logging appears to be the inability to have
per-web application logging,
as the configuration is per-VM. It is advisable to use log4j
for per-web application logging
as elabatorated on below.
</p>
</section>
<section name="log4j">
<p>
As mentioned, an known issue prevents this log4j configuration working
propertly on Tomcat startup,
but is known to work when combined with some actions, such as
deployment of a WAR. It is
provided for completeness.
</p>
<ol>
<li>
Create a file called log4j.properties with the
following content and save it into common/classes.
Use the appropriate file path convention for your OS,
here is is Windows, and example *nix path may be
/var/jakarta-tomcat-5.5.4/logs/tomcat.log
<source>
log4j.rootLogger=debug, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=d:/jakarta-tomcat-5.5.4/logs/tomcat.log
log4j.appender.R.MaxFileSize=500KB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c -
%m%n
log4j.logger.org.apache.catalina=DEBUG, R</source>
</li>
<li>Acquire log4j1.2.8.jar and add it into Tomcat's common/lib
folder.</li>
<li>Start Tomcat</li>
</ol>
<p>
This log4j configuration will set up a file called tomcat.log
in your Tomcat logs folder with
a maximum file size of 500KB and up to 10 backups. DEBUG level
is specified which will result
in the most verbose output from Tomcat. The above can generate
in excess of 5MB of logging with
bundled web applications and Struts web applications.
</p>
<p>
You can of course choose to be more picky about which packages
to include in the logging as with
the JDK Logging. For example try substituting the last line of
the above configuration with one
of these:
<ul>
<li>log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG,
R</li>
<li>log4j.logger.org.apache.catalina.core=DEBUG, R</li>
<li>log4j.logger.org.apache.catalina.session=DEBUG,
R</li>
</ul>
</p>
</section>
<section name="Conclusion">
<p>
The usefulness of what you will find from internal Tomcat
logging is debatable for web
applications. Unless a problem with Tomcat itself exists, it is
probably not required.
</p>
<p>
It is much more common and recommended for web application
themselves to be configured with
a logging setup. In the case of JDK Logging, you could setup
package loggers to collect logging
from your own applications, e.g
<code>com.mycomp.myapp.level=DEBUG</code>. In the case of log4j, a custom
log4j.properties file would be placed into your web
application's WEB-INF/classes folder and
log4j-1.2.8.jar into WEB-INF/lib and the log4j.properties file
would setup a set of
(normally) file appenders to collect the logging, again with
package level setup, e.g
<code>log4j.logger.org.mycomp.myapp=DEBUG,
APPENDER_TO_USE</code>.
</p>
</section>
> -----Original Message-----
> From: Wouter De Vaal [mailto:[EMAIL PROTECTED]
> Sent: 24 November 2004 14:54
> To: Tomcat Users List
> Subject: Re: Tomcat Documentation Thoughts
>
>
> On Wed, 24 Nov 2004 09:44:00 -0500, Shapira, Yoav
> <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > >But you know, I submitted a logging page doc patch over a
> week ago and
> > it's
> > >still not there, and since then there have been many posts
> asking about
> > >this problem. I don't find that encouraging.
> >
> Is this about my problem that I posted earlier today (tomcat 5.5.4 and
> log4j)? About the
> ...[host].[/] problem?
> If so, could you please post your fix on this to me or this list?
>
> Regards,
> Wouter de Vaal
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
<FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE>
-------------------------------------------------------
QAS Ltd.
Developers of QuickAddress Software
<a href="http://www.qas.com">www.qas.com</a>
Registered in England: No 2582055
Registered in Australia: No 082 851 474
-------------------------------------------------------
</FONT>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]