tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lane <l...@joeandlane.com>
Subject Re: confused about simple logging
Date Mon, 23 May 2005 19:03:32 GMT
On Monday 23 May 2005 12:28, Steve Kirk wrote:
> Your confusion possibly arises because there are at least 2 types of logger
> that you might mean, and 3 main choices for one of those at the moment,
> although one of those 3 is deprecated and a second is probably becoming
> less popular.
>
> OK I'll take a quick stab and see if this gets you anywhere in the right
> direction.
>
> You mention two distinct types of logging.  The 1st is the "hit" logging
> which is very similar to what you would get from apache httpd.  This simply
> logs each incoming request.  This is achieved by adding a <Valve> to your
> %catalina_home%\conf\server.xml - you can embed it inside the
> <Host></Host>, <Engine></Engine> or <Context></Context>
tags, but for your
> purposes, just shove it in the engine for now.  It looks a bit like this:
>
> <Engine blah blah>
> 	<Valve
> className="org.apache.catalina.valves.FastCommonAccessLogValve"
> 		directory="logs"  prefix="ao_access_log_" suffix=".log"
> 		pattern="common" resolveHosts="false"/>
> </Engine>
>
> You can tweak the path, filename, and the pattern that defines each line -
> see
> http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/valve.html
> for details.  Leave resolveHosts set "false" to speed up performance.
>
> Not that my example above is from my own 5.5.9 server - ISTR 5.0 config
> syntax is different - check the doc link above for the detail.
>
> The 2nd part of your logging is where you write your own messages to a
> logfile.  I did that as follows:
>
> java.util.logging.Logger logger =
> java.util.logging.Logger.getLogger("logname");
> logger.setLevel(logLevel);
> fh = new FileHandler(logFilePath, maxLogFileSize, logFileCount, true);
> fh.setFormatter(new AoLogFormatter(logFileDateTimePattern));
> logger.addHandler(fh);
>
> Then to write a log message you can just do this:
>
> 	log("Write this to the log");
>
> and it will write the log file to logFilePath
>
> See the java.util.logging.Logger javadocs for more details.
>
> This is very basic.  Much more spophistication can be achieved through
> config files.
>
> > -----Original Message-----
> > From: Lane [mailto:lane@joeandlane.com]
> > Sent: Monday 23 May 2005 18:01
> > To: Tomcat Users List
> > Subject: confused about simple logging
> >
> >
> > Hello.
> >
> > I'm a bit confused about simple logging on tomcat 5.0.  I've
> > read much of the
> > FAQ at
> > http://jakarta.apache.org/tomcat/faq/logging.html#builtIn but that
> > doesn't seem to address what I'm looking for, which is just
> > routine mundane
> > daily activity.
> >
> > For instance, if I create and deploy a simple "Hello World"
> > application that
> > contains only index.jsp, no servlets, no external classes and no JNDI
> > resources, where on earth will a "hit" be recorded when I navigate to
> > http://localhost/helloworld/index.jsp ?  And where is the
> > error recorded if I
> > mistype and navigate to http://localhost/helloworld/jndex.JSP ?
> >
> > Do I have to build such logging into the application?  Or
> > does Catalina handle
> > that for me?  And if so ... where on earth?
> >
> > I'm using FreeBSD installed at /usr/local/jakarta-tomcat5.0
> >
> > I see log information in /usr/local/jakarta-tomcat5.0/logs/stderr.log
> > and /usr/local/jakarta-tomcat5.0/logs/stdout.log but nothing
> > that records a
> > "page hit."
> >
> > Thanks,
> >
> > lane
> >
Thanks, Steven.

I got the <valve> configured and working in server.xml and immediately set 
about trying to make it work only in a specific context.  I guess I just 
can't leave well enough alone :)

You are correct that for my purposes it is alright to log such requests 
"system" (engine || server) wide.

But the documentation at 

http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/context.html#Special+Features

seems to imply such an access log can be maintained per-context.  

I've tried to configure it in 
$CATALINA_HOME/conf/Catalina/localhost/helloworld.xml and in 
$CATALINA_HOME/webapps/hellowworld/WEB-INF/web.xml but the <Valve> seems to 
be ignored unless it is in $CATALINA_HOME/conf/server.xml

I'm set now, but if anybody has information on per-context access logging it'd 
sure help me troubleshoot.

lane

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


Mime
View raw message