javatomcatloggingserver.xml

In tomcat server.xml, can AccessLogValve be defined for service element


I have a tomcat server running perfectly fine apart from writing the access logs. In Server.xml, the access log is defines like below:

     <Server port="xxxx" shutdown="SHUTDOWN">
    <GlobalNamingResources>
            ----
     </GlobalNamingResources>
    <Service name="Catalina">
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="access." suffix=".log" pattern="common" resolveHosts="false"/>
            <Connector --- />
            <Connector --- />
            <Executor --- />
            <Engine name="Catalina" defaultHost="localhost">
                    <Realm ---/>
                    <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"></Host>
            </Engine>
    </Service>

I can see that accesslog valve is defined under service tag and not inside of Engine, host or Context as per common implementation. Can this be the reason behind the server not writing access logs

Official documentation suggesting supporting this: https://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Access_Logs


Solution

  • Got this comment from server.xml :

    A "Service" is a collection of one or more "Connectors" that share a single "Container" Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/service.html