tomcatloggingcontext.xmlaccess-logtomcat-valve

Application-specific accesslog in tomcat?


I am trying to configure independent accesslogs for my .war application in tomcat, but I can't figure out what is failing.

The intention is to have separate access logging for requests going to my application, without having to rely on tomcat's global access log.

I understand that for this I should create my own context config file, with an AccessLogValve specifying where I'll write to.

I have created META-INF/context.xml in my application's WAR file with the content:

<Context path="/Stubby">
    <Valve class="org.apache.catalina.valves.AccessLogValve"
                    rotatable="true"
                    directory="/var/SP/log/stubby"
                    prefix="access.log_"
                    suffix=""
                    fileDateFormat="yyyyMMdd_HH"
                    pattern="combined"
                    buffered="false"
                    resolveHosts="false"
                    />
</Context>

When starting tomcat I see that this file is copied to conf/Catalina/localhost/Stubby.xml, but there is a parse error during the application load routine:

SEVERE: Begin event threw exception
java.lang.NullPointerException
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
(...)
Jul 13, 2011 6:16:12 PM org.apache.catalina.startup.ContextConfig processContextConfig
SEVERE: Parse error in context.xml for /Stubby
java.lang.NullPointerException
        at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2806)
        at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2832)
        at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1359)

What is wrong here? Am I missing any mandatory property in the declaration?


Solution

  • Dumb mistake... Where it reads

    <Valve class="org.apache.catalina.valves.AccessLogValve"
    

    it should be

    <Valve className=...
    

    after this fix, the config works as expected, deployed from META-INF.