JMeter在哪里保存测试/应用程序日志?

JBT*_*JBT 7 java jmeter

我想从我的测试(或应用程序,如果你)监视日志.例如,我可能在代码中有一个日志行,如下所示:

logger.info( "dummy log" );
Run Code Online (Sandbox Code Playgroud)

但是,当我像这样运行JMeter时:

jmeter -n -t foobar.jmx
Run Code Online (Sandbox Code Playgroud)

我不知道在哪里寻找那个虚拟日志.那么,JMeter在哪里保留测试中的日志?更好的是,我该如何配置它?

非常感谢你.

更新
我忘了提到在默认日志文件中找不到测试日志jmeter.log.jmeter.log除非有一些设置禁用测试日志的输出,否则测试日志应该出现?

更新2
我在这里贴了jmeter.properties:http://pastebin.com/6paTqRrK

以下是相关的代码段.

package foo.bar;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.Assert.assertTrue;

public class DummyTest {
    private static final Logger logger = LoggerFactory.getLogger( DummyTest.class.getName() );

    @Test
    public void test(){
        System.out.println("dummy message");
        logger.info("dummy log");
        assertTrue( true );
    }
}
Run Code Online (Sandbox Code Playgroud)

Gradle build.gradle:

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.2.1'

    compile 'org.slf4j:slf4j-api:1.7.5'
    runtime 'ch.qos.logback:logback-classic:1.0.13'
    runtime 'ch.qos.logback:logback-core:1.0.13'

    testCompile 'junit:junit:4.11'
}

// bundle everything into a fat jar
jar {
    from {
        configurations.testRuntime.collect {
            it.isDirectory() ? it : zipTree(it)
        } + sourceSets.main.output + sourceSets.test.output

    }
    archiveName = 'junit_sampler.jar'
}

task updateJar( type: Copy, dependsOn: jar ) {
    from './junit_sampler.jar'
    into "${System.properties['user.home']}/opt/apache-jmeter-2.11/lib/junit"
}
Run Code Online (Sandbox Code Playgroud)

foob​​ar.jmx:

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.6" jmeter="2.11 r1554548">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Check Logging" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">3</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <longProp name="ThreadGroup.start_time">1399656770000</longProp>
        <longProp name="ThreadGroup.end_time">1399656770000</longProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <JUnitSampler guiclass="JUnitTestSamplerGui" testclass="JUnitSampler" testname="JUnit Request" enabled="true">
          <stringProp name="junitSampler.classname">foo.bar.DummyTest</stringProp>
          <stringProp name="junitsampler.constructorstring"></stringProp>
          <stringProp name="junitsampler.method">test</stringProp>
          <stringProp name="junitsampler.pkg.filter"></stringProp>
          <stringProp name="junitsampler.success">Test successful</stringProp>
          <stringProp name="junitsampler.success.code">1000</stringProp>
          <stringProp name="junitsampler.failure">Test failed</stringProp>
          <stringProp name="junitsampler.failure.code">0001</stringProp>
          <stringProp name="junitsampler.error">An unexpected error occured</stringProp>
          <stringProp name="junitsampler.error.code">9999</stringProp>
          <stringProp name="junitsampler.exec.setup">false</stringProp>
          <stringProp name="junitsampler.append.error">false</stringProp>
          <stringProp name="junitsampler.append.exception">false</stringProp>
          <boolProp name="junitsampler.junit4">true</boolProp>
        </JUnitSampler>
        <hashTree/>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>
Run Code Online (Sandbox Code Playgroud)

不知何故,"虚拟日志"消息只是没有出现在jmeter.log中.

Dmi*_*i T 5

默认情况下,所有日志记录都会保存到jmeter.log通常位于 JMeter 安装的 /bin 文件夹中的文件中。但是,该位置可能会根据您启动 JMeter 的方式及其工作目录而有所不同。有关更多详细信息,请参阅文件服务器API。

如果您想要记录来自自定义类、扩展或插件的输出,它可能会被配置抑制。尝试通过属性“告诉”JMeter 您的类所需的日志级别。

请参阅user.propertiesJMeter 安装的 /bin 文件夹中的文件以获取示例日志记录级别配置,并参阅Apache JMeter 属性自定义指南以了解如何更改它们。

但是我很确定如果您logger按如下方式初始化:

import org.apache.jorphan.logging.LoggingManager;
...
...
private static final Logger logger = LoggingManager.getLoggerForClass(); 
...
logger.info("sonething");
Run Code Online (Sandbox Code Playgroud)

您将在日志中看到“某事”行。

希望这可以帮助。


Nid*_*esh 0

日志文件名在jmeter.properties文件中定义(或使用 -j 选项,见下文)。它默认为jmeter.log,可以在启动 JMeter 的目录中找到

http://jmeter.apache.org/usermanual/get-started.html#logging