停止记录 Gatling 请求

Stop logging Gatling Requests

我正在监控许多网页(大约 4000 个),它们的 URL 由同一 Gatling 测试中的 CSV 文件提供。

问题是测试永远持续下去。我想(但它可能不是真的)日志记录 activity 需要很长时间。所以我想停止使用巨大的 table 和

---- Requests ------------------------------------------------------------------
> Whatever
> Blah blah blah
> And so on
---- Errors --------------------------------------------------------------------
> You got it

...只是为了看看它是否让我的测试持续时间更短。

我该怎么办?

我尝试编辑我的 logback-test.xml 文件,但日志显示即使是 ERROR 级别。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
            <immediateFlush>true</immediateFlush>
        </encoder>
    </appender>

    <!-- Uncomment for logging ALL HTTP request and responses -->
    <!--    <logger name="io.gatling.http.ahc" level="TRACE" /> -->
    <!--    <logger name="io.gatling.http.response" level="TRACE" /> -->
    <!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
    <!--    <logger name="io.gatling.http.ahc" level="DEBUG" /> -->
    <!--    <logger name="io.gatling.http.response" level="DEBUG" /> -->

    <root level="ERROR">
        <appender-ref ref="CONSOLE" />
    </root>

</configuration>

此外,出于所有目的,这是我的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>dead_url_spotter</groupId>
    <artifactId>dead_url_spotter</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <scala.version>2.11.7</scala.version>
        <encoding>UTF-8</encoding>

        <gatling.version>2.2.3</gatling.version>

        <scala-maven-plugin.version>3.2.2</scala-maven-plugin.version>
        <gatling.maven.version>2.2.1</gatling.maven.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.gatling</groupId>
                <artifactId>gatling-app</artifactId>
                <version>${gatling.version}</version>
            </dependency>
            <dependency>
                <groupId>io.gatling</groupId>
                <artifactId>gatling-recorder</artifactId>
                <version>${gatling.version}</version>
            </dependency>
            <dependency>
                <groupId>io.gatling.highcharts</groupId>
                <artifactId>gatling-charts-highcharts</artifactId>
                <version>${gatling.version}</version>
            </dependency>
            <dependency>
                <groupId>org.scala-lang</groupId>
                <artifactId>scala-library</artifactId>
                <version>${scala.version}</version>
            </dependency>
            <dependency>
                <groupId>com.typesafe.scala-logging</groupId>
                <artifactId>scala-logging_2.12</artifactId>
                <version>3.7.2</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>LATEST</version>
        </dependency>
        <dependency>
            <groupId>io.gatling.highcharts</groupId>
            <artifactId>gatling-charts-highcharts</artifactId>
        </dependency>
        <dependency>
            <groupId>io.gatling</groupId>
            <artifactId>gatling-app</artifactId>
        </dependency>
        <dependency>
            <groupId>io.gatling</groupId>
            <artifactId>gatling-recorder</artifactId>
        </dependency>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>org.json</artifactId>
            <version>LATEST</version>
        </dependency>
        <dependency>
            <groupId>com.cedarsoftware</groupId>
            <artifactId>json-io</artifactId>
            <version>4.9.8</version>
        </dependency>
        <dependency>
            <groupId>org.jmxtrans</groupId>
            <artifactId>jmxtrans</artifactId>
            <version>263</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.11.2</version>
        </dependency>
    </dependencies>

    <build>
        <testSourceDirectory>src/test/java</testSourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                    <version>${scala-maven-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.gatling</groupId>
                <artifactId>gatling-maven-plugin</artifactId>
                <version>2.2.1</version>
                <configuration>
                    <jvmArgs>
                        <jvmArg>-Durl=http://localhost:9000</jvmArg>
                        <jvmArg>-DnumberOfUsers=10</jvmArg>
                        <jvmArg>-DnumberOfRepetitions=1</jvmArg>
                        <jvmArg>-DdurationMinutes=1</jvmArg>
                        <jvmArg>-DpauseBetweenRequestsMs=3000</jvmArg>
                        <jvmArg>-Ddebug=false</jvmArg>
                    </jvmArgs>
                    <configFolder>src/test/resources</configFolder>
                    <dataFolder>src/test/resources/data</dataFolder>
                    <resultsFolder>target/gatling/results</resultsFolder>
                    <bf>src/test/resources/bodies</bf>
                    <simulationsFolder>src/test/scala</simulationsFolder>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                        <configuration>
                            <args>
                                <arg>-Ybackend:GenBCode</arg>
                                <arg>-Ydelambdafy:method</arg>
                                <arg>-target:jvm-1.8</arg>
                                <arg>-deprecation</arg>
                                <arg>-feature</arg>
                                <arg>-unchecked</arg>
                                <arg>-language:implicitConversions</arg>
                                <arg>-language:postfixOps</arg>
                            </args>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.20.1</version>
                <configuration>
                    <skip>${skip.selenium.tests}</skip>
                    <parallel>none</parallel>
                    <threadCount>1</threadCount>
                    <reuseForks>false</reuseForks>
                    <disableXmlReport>false</disableXmlReport>
                </configuration>
                <executions>
                    <execution>
                        <id>runSeleniumTests</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

在此先感谢您的帮助。

我的问题已在 Gatling issues section 得到解答;这可以在 gatling.conf 文件中配置(在 test/resources 中)。

而不是:

gatling {
  data {
    writers = [console, file]
  }
}

您可以拥有:

gatling {
  data {
    writers = [file]
  }
}

现在您的控制台已清除。

如果您需要了解更多有关 gatling.conf file default values 的信息,请查看此内容。