Whenever I run a new jmeter command from the CLI a new jmeter.log file is generated and I lose the contents written by the previous test run.
Example:
First I run the test script with:
jmeter -n -p .\config.properties -t .\path\to\jmeterScripFile.jmx -l .\path\to\jmeterScriptOutputFile.jtl
This generates a fresh jmeter.log file.
Then I run this command to generate a HTML Dashboard report:
jmeter -g .\path\to\jmeterScriptOutputFile.jtl -o .\path\to\TestResults\ReportHTML
This 2nd command overrides the previous jmeter.log file contents.
I would like each jmeter CLI command to generate a unique.log file. Something like jmeter-yyyymmdd-hhMMss
How could I achieve this?
You can override the default jmeter.log
file name using -j
command-line argument like
jmeter -j your-custom-log-name-here.log -n -t.....
the timestamp can be added by means of your operating system
If you want to make the change permanent and don't want to provide the new log file name via -j
command-line argument you can amend the log file prefix via log4j2.xml file like
change this line:
<File name="jmeter-log" fileName="${sys:jmeter.logfile:-jmeter.log}" append="false">
to something like:
<File name="jmeter-log" fileName="jmeter-${date:yyyyMMdd-hh-mm-ss}.log" append="false">
More information:How to Configure JMeter Logging
JMeter command line option -j
will allow you to specify the jmeter log file. Name of the file can be set dynamically. If you are on Mac $(date +%Y%m%d-%H%M%S)
can be used for getting the timestamp.
-j [name of JMeter run log file].
You can use following command with current time stamps suffix to the jmeter log file. The log file will be create in your JMETER_HOME/bin folder.
./jmeter -n -t TestPlan-Basic-Test.jmx -j jmeter-$(date +%Y%m%d-%H%M%S).log -l test-result.csv
Similar could be used on widows. link
You can follow this simple example the date here generates date now:
jmeter -g ./path/to/"`date`".jtl -o ./path/to/TestResults/ReportHTML
Extra: In case you want dates separated by underscores you can use this
DN="`date`"
DATE_NOW=${DN// /_}
jmeter -g ./path/to/$DATE_NOW.jtl -o ./path/to/TestResults/ReportHTML
PS : Don't forget to do the same thing for the other command.
Date Example would look something like this Sun_Dec__5_00:55:38_WCAST_2021
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.