英文:
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>
</Server>
我可以看到访问日志阀门是在service标签下定义的,而不是在Engine、Host或Context内部,这可能是服务器不写入访问日志的原因吗?
官方文档建议支持这种配置:https://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Access_Logs
英文:
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>
</Server>
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
答案1
得分: 2
从server.xml中获得了以下注释:
> 一个“Service”是一个包含一个或多个“Connectors”的集合,它们共享
一个单独的“Container” 注意:一个“Service”本身不是一个“Container”,
因此您不能在这个级别定义诸如“Valves”之类的子组件。
文档位于/docs/config/service.html
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论