在tomcatserver.xml中,是否可以为服务元素定义AccessLogValve

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

我有一个 tomcat 服务器 运行 除了写入访问日志外完全没问题。 在Server.xml中,访问日志定义如下:

     <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>

我可以看到 accesslog valve 是在服务标签下定义的,而不是在引擎、主机或上下文中按照常见的实现方式定义的。这可能是服务器不写入访问日志的原因吗

建议支持这一点的官方文档:https://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Access_Logs

从 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