Send jmeter.log also to console standard output

Viewed 921

When JMeter start with non-gui mode, It shows some logs on the console as below

342-MC-C02Y33GKJG5H:bin asankav$ ./jmeter -n -t /Users/asankav/myarea/jmetertest/Demo.jmx

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/asankav/software/apache-jmeter-5.1.1/lib/log4j-slf4j-impl-2.11.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/asankav/software/apache-jmeter-5.1.1/lib/ext/qperf_core-0.0.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Creating summariser <summary>

But actual test execution logs writes to a separate log file called jmeter.log, It logs log4J level execution logs.

342-MC-C02Y33GKJG5H:bin asankav$ tail -f -n 500 jmeter.log
2020-06-04 11:53:58,710 INFO o.a.j.u.JMeterUtils: Setting Locale to en_EN
2020-06-04 11:53:58,728 INFO o.a.j.JMeter: Loading user properties from: user.properties
2020-06-04 11:53:58,729 INFO o.a.j.JMeter: Loading system properties from: system.properties
2020-06-04 11:53:58,733 INFO o.a.j.JMeter: Copyright (c) 1998-2019 The Apache Software Foundation
2020-06-04 11:53:58,733 INFO o.a.j.JMeter: Version 5.1.1 r1855137
2020-06-04 11:53:58,733 INFO o.a.j.JMeter: java.version=1.8.0_221
2020-06-04 11:53:58,733 INFO o.a.j.JMeter: java.vm.name=Java HotSpot(TM) 64-Bit Server VM
2020-06-04 11:53:58,733 INFO o.a.j.JMeter: os.name=Mac OS X
2020-06-04 11:53:58,733 INFO o.a.j.JMeter: os.arch=x86_64
2020-06-04 11:53:58,733 INFO o.a.j.JMeter: os.version=10.15.4
2020-06-04 11:53:58,733 INFO o.a.j.JMeter: file.encoding=UTF-8
2020-06-04 11:53:58,733 INFO o.a.j.JMeter: java.awt.headless=true
2020-06-04 11:53:58,733 INFO o.a.j.JMeter: Max memory     =1073741824
2020-06-04 11:53:58,733 INFO o.a.j.JMeter: Available Processors =12
2020-06-04 11:53:58,736 INFO o.a.j.JMeter: Default Locale=English (EN)
2020-06-04 11:53:58,736 INFO o.a.j.JMeter: JMeter  Locale=English (EN)

Can we direct this jmeter.log content also to STDOUT console? I know we can pipe the log to the console. but is there a way to do this using JMeter configuration?

I'm running JMeter as a container on Kubernetes cluster and want to get jmeter.log content to the console. So those logs will be available on the container log and can view them via the Kubernetes dashboard.

Appreciate your ideas.

1 Answers

Update log4j2.xml in bin folder

Add under <Appenders>

<Console name="console" target="SYSTEM_OUT">
    <PatternLayout pattern="[%highlight{%-5level}] %d{DEFAULT} %c{1}.%M() - %msg%n%throwable{short.lineNumber}" />
</Console>

Add under <Root level="info">

<AppenderRef ref="console" />

So every log will be also written to console

Related