tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dr. Evil" <dre...@sidereal.kz>
Subject Writing my own valve to do extra logging
Date Sat, 09 Mar 2002 02:02:51 GMT

Hi, I have found that I need to write my own access logging mechanism
to work with Tomcat.  I need the ability to log to a database and do
other things that the built-in mechanism simply can't do.  Extremely
good database-searchable real-time logging is critical to this project.

One way to do this is to write a logging filter.  Unfortunately this
doesn't give me all the info I need.  I need to be able to capture all
response codes, content length, etc.  Even if I write a class that
extends HttpServletResponseWrapper and use a filter to use that
response object, it doesn't catch all the info I need (trust me, I've
tried this).

So my solution is to write a valve which will replace the built-in
org.apache.catalina.valves.AccessLogValve valve.  It's very easy to
write a valve, but in this case, I simply copied the catalina valve,
adjusted import directives so it would compile, compiled it, and put
it in CATALINA/server/lib/mylogger.jar.

Then I edited bin/catalina.sh so that mylogger.jar was on the java
classpath, and edited server.xml so that instead of <Valve
className="org.apache.catalina.AccessLogValve" it was <Valve
className="kz.sidereal.valves.AccessLogValve"

At that point I restarted the server and in catalina.out, I got an
exception:

Exception during startup processing
java.lang.reflect.InvocationTargetException: java.lang.NoClassDefFoundError: org/apache/catalina/valves/ValveBase
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
        at org.apache.catalina.loader.StandardClassLoader.loadClass(Unknown Source)
        at org.apache.catalina.loader.StandardClassLoader.loadClass(Unknown Source)
        at org.apache.catalina.loader.StandardClassLoader.loadClass(Unknown Source)
        at org.apache.catalina.loader.StandardClassLoader.loadClass(Unknown Source)

I have no idea what I'm doing wrong here.  Does anyone have any ideas
on how to replace this particular valve so that I can write my own
logger?

Thanks for any tips.

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message