简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM