Apache tomcat,每个虚拟主机的日志文件

时间:2014-03-28 11:16:59

标签: tomcat logging virtualhost

<Server port="8005" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.core.JasperListener" />
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
    <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

    <GlobalNamingResources>
        <Resource name="UserDatabaseReal" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users-real.xml" />

        <Resource name="UserDatabaseTest" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users-test.xml" />
    </GlobalNamingResources>

    <Service name="Catalina">
        <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               URIEncoding="UTF-8"
               redirectPort="8443" />

        <Engine name="Catalina" defaultHost="webapps">
            <Realm className="org.apache.catalina.realm.LockOutRealm">
                <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabaseReal"/>
            </Realm>

            <Host name="webapps" appBase="webapps" unpackWARs="true" autoDeploy="true" ctreateDirs="true">
                <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" 
                prefix="webapps-log." suffix=".log" 
                timestamp="true"/>

                <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="webapps-access-log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
            </Host>
        </Engine>
    </Service>

    <Service name="CatalinaTest">
        <Connector port="8088" protocol="HTTP/1.1"
               connectionTimeout="20000"
               URIEncoding="UTF-8"
               redirectPort="8443" />

        <Engine name="CatalinaTest" defaultHost="webapps-test">
            <Realm className="org.apache.catalina.realm.LockOutRealm">
                <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabaseTest"/>
            </Realm>

            <Host name="webapps-test" appBase="webapps-test" unpackWARs="true" autoDeploy="true" createDirs="true">
                <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" 
                prefix="webapps-test-log." suffix=".log" 
                timestamp="true"/>

                <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="webapps-test-access-log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
            </Host>
        </Engine>
    </Service>
</Server>

这是我的tomcat服务器的配置。我希望每个虚拟主机都有日志文件。我将Logger标记放入Host标记,但这不起作用。你能告诉我如何配置这种行为吗?

0 个答案:

没有答案