How to change log.info/error message's font color in Jmeter's JSR223? - groovy

I'm trying to find a way to change log.info/error message's font color so that it would be easier for me to read messages in Jmeter's JSR223 Log section
any advice ?
thanks,

As per current version (JMeter 4.0) I don't think it is possible. You can use Groovy Coloriser library if you want, however it will only work for println statements, not for JMeter's log.error
The only way you can filter out the log output to errors only is configuring JMeter logging subsystem to display only messages of ERROR level (or above). You can do this in at least 2 ways:
Locate <Root level="info"> line in log4j2.xml file (lives in "bin" folder of your JMeter installation) and change info to error. JMeter restart will be required to pick the property up
Or you can simply run JMeter like jmeter -LERROR
In both cases you will not be seeing all these INFO and/or WARN messages anymore, you will see only ERROR and above.
More information:
Overriding Properties Via The Command Line
How to Configure JMeter Logging

Related

The prev variable displays a warning message in groovy, is it normal?

1.add JSR223Sample
2.add follow values:
${__Sms_String_Encrypt(${__groovy(import groovy.json.JsonSlurper ;def respone = prev.getResponseDataAsString();new JsonSlurper().parseText(respone).result,)},${secretKey},2,re)}
3.Please allow me to attach a screenshot.
Why is this warning message prompted?
Why is it normal to add prev variable references in the script area?For example: prev.getTime().toString())
It sounds like a bug in JMeter to it worth reporting it to JMeter Bugzilla
Until it's fixed the options are in:
Ignore the warning as the function will still do its job
Decrease JMeter logging verbosity for __groovy() function by adding the next line log4j2.xml file
<Logger name="org.apache.jmeter.functions.Groovy" level="error"/>
this way you will stop seeing the message in the jmeter.log file
Extract data from the response using JSR223 PostProcessor or JSON Extractor or JSON JMESPath Extractor and use variables, not the groovy function in the "Parameters" section

Cannot change zookeeper log filename

Zookeeper is creating the logs with a name zookeeper-root-hostname.out but this is my log4j.properties:
zookeeper.root.logger=INFO, CONSOLE
zookeeper.console.threshold=INFO
zookeeper.log.dir=.
zookeeper.log.file=zookeeper.log
zookeeper.log.threshold=INFO
zookeeper.log.maxfilesize=256MB
zookeeper.log.maxbackupindex=20
zookeeper.tracelog.dir=${zookeeper.log.dir}
zookeeper.tracelog.file=zookeeper_trace.log
log4j.rootLogger=${zookeeper.root.logger}
#
# console
# Add "console" to rootlogger above if you want to use this
#
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold}
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}#%L] - %m%n
#
# Add ROLLINGFILE to rootLogger to get log file output
#
log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold}
log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file}
log4j.appender.ROLLINGFILE.MaxFileSize=${zookeeper.log.maxfilesize}
log4j.appender.ROLLINGFILE.MaxBackupIndex=${zookeeper.log.maxbackupindex}
log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}#%L] - %m%n
If a change the property zookeeper.log.file=zookeeper.log the file is created with the same name, How can I change the filename of the log?
Update
I found that the file zkServer.sh set the variable ZOO_LOG_FILE and overrides the value that is define in the log4j.properties:
ZOO_LOG_FILE=zookeeper-$USER-server-$HOSTNAME.log
I can modify this file but Is it ok to change that manually?
In typical Java application fashion the logging situation with Zookeeper is incredibly complicated, custom, and poorly documented. The official Administrators manual logging section is a tiny paragraph with about zero information, but suggests you can rely on your existing knowledge of the third party library log4j configured to proxy through the other third party library SLF4J. This actually wouldn't be too bad since that complicated arrangement is common as many popular open source projects ignore the built-in logging framework that ships will Java, but later you'll discover using the log4j.properties file in the conf directory actually doesn't work as expected because custom properties are used in the provided start up script (zkServer.sh) that override many things.
In order to set the file name note the file conf/log4j.properties contains the following variable assignment that is overridden by the start up script (zkServer.sh):
zookeeper.log.file=zookeeper.log
Either set the environment variables externally, modify the start up script or update the log4j.properties to not use the variable:
#log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file}
log4j.appender.ROLLINGFILE.File=/the/actual/path/goes/here.log
You may also want to enable the ROLLINGFILE like so:
#log4j.rootLogger=${zookeeper.root.logger}
log4j.rootLogger=INFO,ROLLINGFILE
After searching I found this link but I didn't found how to change the variable for the log, I noticed that inside the file zkServer.sh is defined the name of the file, so I needed to change this variable:
_ZOO_DAEMON_OUT="$ZOO_LOG_DIR/zookeeper-$USER-server-$HOSTNAME.out"
I don't know if it's ok to change that variable but now is working as expected.

Jmeter cmdrunner observed garbage characters

Please need some advise how to resolve this characters, thanks.
command:
java -jar apache-jmeter-4.0/lib/cmdrunner-2.2.jar --tool Reporter --generate-png tps_L1.png --input-jtl jmeter.jtl --plugin-type TransactionsPerSecond --width 1024 --height 768
Environment:
CentOS v7.3
Jmeter v4.0
It might be caused by your test using non-ASCII characters for Thread Group(s) and Sampler(s) labels.
First of all double check JMeter doesn't have problems with storing/interpreting Thread Group and Sampler labels, i.e. try generating HTML Reporting Dashboard (it includes Transactions per Second chart by the way)
If the problem remains - you need to find a way to configure JMeter to handle national characters, i.e. try explicitly defining file.encoding property to be UTF-8. To do this add the next line to system.properties file (lives in "bin" folder of your JMeter installation)
file.encoding=UTF-8
and restart JMeter to pick the property up
If it helps - play the same trick with JMeter Plugins CMDRunner tool, like:
java -Dfile.encoding=UTF-8 -jar apache-jmeter-4.0/lib/cmdrunner-2.2.jar --tool Reporter --generate-png tps_L1.png --input-jtl jmeter.jtl --plugin-type TransactionsPerSecond --width 1024 --height 768
Also be aware that according to JMeter Best Practices you should always be using the latest version of JMeter so consider upgrading to JMeter 5.0 (or whatever the latest version is available at JMeter Downloads page) as soon as possible

How to use log4j write logs into a mysql database on Jmeter?

Jmeter default write logs into a file named "jmeter.log".But there is a file named "log4j.conf" under the folder "bin". I confused about how to use it. Anyone can help me ?
please check in the conf
# 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
# For logging configuration of JMeter, it needs to be done in user.properties
how it works.
If you have special sampler that uses java code .. in that java code if you use log.info , log.error, log.warn statements it prints that to jmeter.log Hope this helps
If you have jsr223 groovy sampler try putting below line and check jmeter.log you see the logging info.
log.info "check this in jmeter.log"
Hope this helps ..

py.test : logging the number of failures

Can I catch the failures found by py.test ? I would like to build a log where I will write the numbers of failures and also the OS tested.
You can log a machine readable result file for this purpose using:
py.test --resultlog=path
Documentation is available here. This file is what many other tools use to inspect the output of a py.test run and, for example, compare results between different runs.
Apart from --resultlog which #srowland showed, you can also use --junitxml to write a JUnit XML file, or write your own plugin to log in a custom format.

Resources