2

部署到 Tomcat 服务器和应用程序日志打印时一切正常。但是当我使用时, mvn tomcat7:run没有打印应用程序日志。我的配置如下:

web.xml

    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>classpath:log4j-shoppingcart.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

pom.xml

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <systemProperties>
            <java.util.logging.config.file>src/main/resources/log4j-shoppingcart.xml</java.util.logging.config.file>
        </systemProperties>
        <extraDependencies>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.7</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jul-to-slf4j</artifactId>
                <version>1.7.7</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactI>
                <version>1.7.7</version>
            </dependency>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>
        </extraDependencies>
    </configuration>
</plugin>

这些链接在一定程度上帮助了我,但没有打印应用程序日志。任何帮助都会有很大帮助。

4

0 回答 0