gpt4 book ai didi

tomcat - Apache Tomcat 为多个应用程序记录多个服务

转载 作者:行者123 更新时间:2023-11-28 23:04:54 25 4
gpt4 key购买 nike

我已将 Tomcat server.xml 配置为具有多个连接器:

   <Service name="Catalina">

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="C:\somekey.keystore" keystorePass="mykeypass"
clientAuth="false" sslProtocol="TLSv1" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="access_log." suffix=".txt" pattern='%h %l %u %t "%r" %s %b %p %D %S' resolveHosts="false"/>
</Host>
</Engine>

<Engine name="CatalinaA" defaultHost="localhost">

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>

<Host name="localhost" appBase="webappsA"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logsA"
prefix="access_log_A." suffix=".txt" pattern='%h %l %u %t "%r" %s %b %p %D %S' resolveHosts="false"/>

</Host>
</Engine>

我还部署了两个 Web 应用程序,一个在 webapps (APPP1) 中,另一个在 webappsA (APPP2) 中。
这是我的 logging.properties:

         handlers = 2APPP1.org.apache.juli.FileHandler, 3APPP2.org.apache.juli.FileHandler
.handlers = 2APPP1.org.apache.juli.FileHandler, 3APPP2.org.apache.juli.FileHandler

2APPP1.org.apache.juli.FileHandler.level = FINEST
2APPP1.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2APPP1.org.apache.juli.FileHandler.prefix = APPP1.

3APPP2.org.apache.juli.FileHandler.level = FINEST
3APPP2.org.apache.juli.FileHandler.directory = ${catalina.base}/logsA
3APPP2.org.apache.juli.FileHandler.prefix = APPP2.

java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[/APPP1].level = INFO
org.apache.catalina.core.ContainerBase.[CatalinaA].[/APPP2].level = INFO

org.apache.catalina.core.ContainerBase.[Catalina].[/APPP1].handlers = 2APPP1.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[CatalinaA].[/APPP2].handlers = 3APPP2.org.apache.juli.FileHandler
org.apache.catalina.level = WARNING

日志被分离到不同的文件夹,两个应用程序的访问日志都可以,但是 Tomcat 日志将每个应用程序请求都记录到 APPP1.log 和 APPP2.log 文件中。

最佳答案

通过包括行:

.handlers = 2APPP1.org.apache.juli.FileHandler, 3APPP2.org.apache.juli.FileHandler

您正在将这两个文件处理程序分配给根记录器。与这些文件处理程序中的每一个关联的文件正在从默认记录器获取输出(即所有输出)。

关于tomcat - Apache Tomcat 为多个应用程序记录多个服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11458792/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com