2

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
André Fernandes
  • 2,335
  • 3
  • 25
  • 33

2 Answers2

5

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.

André Fernandes
  • 2,335
  • 3
  • 25
  • 33
0

I suspect what you are dealing with is a class loader issue: the valve classes may not be available to the class loader that is copying the context xml. I wouldn't think that would be the case, but if you remove the context.xml file from META-INF and copy it into conf/Catalina/localhost/Stubby.xml does the valve work correctly?

Femi
  • 64,273
  • 8
  • 118
  • 148
  • removing the xml file from META-INF and keeping the one on conf/Catalina/localhost no longer generates an exception, but the application is still not writing any logs... – André Fernandes Jul 14 '11 at 08:36