0

我正在尝试为基于 spring 的 tomcat 应用程序配置 logback-access。在我的 pom.xml 文件中添加了以下行:

                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                    <version>${slf4j.version}</version>
                    <scope>runtime</scope>
                </dependency>
                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                    <version>${slf4j.version}</version>
                    <scope>runtime</scope>
                </dependency>
                <dependency>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                    <version>${logback.version}</version>
                    <scope>runtime</scope>
                </dependency>
                <dependency>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-core</artifactId>
                    <version>${logback.version}</version>
                    <scope>runtime</scope>
                </dependency>
                <dependency>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-access</artifactId>
                    <version>${logback.version}</version>
                    <scope>runtime</scope>
                </dependency>   

我还在 pom 文件的 tomcat 插件配置中添加了这个。

       <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat6-maven-plugin</artifactId>
            <version>${maven.tomcat.plugin}</version>           
            <configuration>
                <systemProperties>
                    <java.util.logging.manager>org.apache.juli.ClassLoaderLogManager</java.util.logging.manager>
                    <logback.ContextSelector>JNDI</logback.ContextSelector>
                </systemProperties>
            </configuration>                
            <dependencies>
                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                    <version>${slf4j.version}</version>
                    <scope>runtime</scope>
                </dependency>
                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                    <version>${slf4j.version}</version>
                    <scope>runtime</scope>
                </dependency>
                <dependency>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                    <version>${logback.version}</version>
                    <scope>runtime</scope>
                </dependency>
                <dependency>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-core</artifactId>
                    <version>${logback.version}</version>
                    <scope>runtime</scope>
                </dependency>
                <dependency>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-access</artifactId>
                    <version>${logback.version}</version>
                    <scope>runtime</scope>
                </dependency>   
            </dependencies>
        </plugin>

我已将资源文件放在以下位置: src/main/resources/logback.xml src/main/resources/logback-access.xml

但是当 logback.xml 工作时,tomcat 无法获取 logback-access.xml 文件。如何使用我的 tomcat6 插件附加访问 xml 文件?

4

1 回答 1

0

我也在尝试相同的方法,但我发现 tomcat6/7-maven-plugin 没有能力运行这些配置,因为这必须在容器级别进行配置,请参阅http://logback.qos.ch/access.html #tomcat

您可以使用“cargo-maven2-plugin”在现有容器中运行应用程序并将该容器配置为 logback-access

像这样配置货物

         <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>${cargo.maven.plugin}</version>
            <configuration>
                <container>
                    <containerId>tomcat7x</containerId>
                    <type>installed</type>
                    <home>${tomcat.home}</home>
                    <timeout>1800000</timeout> 
                </container>
                <configuration>
                    <type>existing</type>
                    <home>${tomcat.home}</home>
                </configuration>
                <deployables>
                    <deployable>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>YOUR_WEB_ARTIFICT</artifactId>
                        <type>war</type>
                    </deployable>
                </deployables>
            </configuration>
        </plugin>

我使用了货物插件版本 1.3.3

然后执行 cargo:deployer-deploy

和货物:运行或货物:开始

于 2013-04-16T06:13:35.197 回答