Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does JMeter keep test/application logs?

Tags:

java

jmeter

I want to monitor the logs from my tests (or applications if you will). For example, I might have a log line in the code like this:

logger.info( "dummy log" );

However, when I run JMeter like this:

jmeter -n -t foobar.jmx

I have no idea where to look for that dummy log. So, where does JMeter keep the logs from the tests? Better yet, how can I configure it?

Thank you very much.

update
I forgot to mention that the test logs were not found in the default log file jmeter.log. Is that true that the test logs should appear in the jmeter.log unless there are some settings disabling the output of the test logs?

update 2
I have pasted the jmeter.properties here: http://pastebin.com/6paTqRrK

Below are relevant code snippets.

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 );
    }
}

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"
}

foobar.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>

Somehow, the "dummy log" message just doesn't show up in the jmeter.log.

like image 349
JBT Avatar asked May 08 '14 21:05

JBT


People also ask

Where are JMeter logs stored?

Since JMeter version 3.2, logging is configured through an Apache Log4j 2 configuration file. The configuration file (log4j2. xml) is located in the bin directory of your JMeter.

Which of the following is a JMeter log level option?

You can configure the Log level by selecting INFO, WARN, ERROR, DEBUG, TRACE from the top menu. DEBUG and TRACE logs everything about the test. Request, response, headers, JMeter status with Threads, etc… WARN will log only the warning generated by JMeter.


2 Answers

By default all logging goes to jmeter.log file which is usually located in /bin folder of your JMeter installation. However the location may vary basing on how you launch JMeter and what would be it's working directory. See FileServer API for more details.

If you want logging output from a custom class, extension or plugin it might be supressed by configuration. Try "telling" JMeter the desired log level for your class via property.

See user.properties file in /bin folder of your JMeter installation for sample logging levels configuration and Apache JMeter Properties Customization Guide for how to change them.

However I'm pretty sure that if you initialize your logger as follows:

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

You will see that "something" line in the log.

Hope this helps.

like image 143
Dmitri T Avatar answered Oct 20 '22 00:10

Dmitri T


For JMeter 2.13 you need to edit bin/log4j.conf where general log4j settings can be placed. For example, the bin/root.log file will be recorded as specified below:

###############################  IMPORTANT NOTE  ##############################
# JMeter does not use log4j as logging system
# This configuration will only be used by libraries that do use log4j
# or your custom code if it uses it

log4j.appender.Root_Appender=org.apache.log4j.RollingFileAppender
log4j.appender.Root_Appender.File=root.log
log4j.appender.Root_Appender.Append=true
log4j.appender.Root_Appender.MaxBackupIndex=0
log4j.appender.Root_Appender.layout=org.apache.log4j.PatternLayout
log4j.appender.Root_Appender.layout.ConversionPattern=%-5p %d{MM/dd, hh:mm:ss} %-20.30c %m%n

log4j.rootCategory=DEBUG,Root_Appender
like image 45
vim Avatar answered Oct 20 '22 00:10

vim