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's contents.
I would like each jmeter CLI command to generate a unique .log file. Something like jmeter-yyyymmdd-hhMMss
How could I achieve this?
Several ideas: Either provide a fresh filename as a startup option manually or edit logging config to do this for you automatically.
You can override the default jmeter.log
file name using the -j
command-line argument and add the timestamp via your operating system shell.
For example on Linux:
jmeter -j "jmeter.$(date +%s).log" -n -t .....
If you want to make the change permanent and don't want to provide the new log file name via -j
command-line argument then you can amend the log file prefix via the log4j2.xml
file like so:
Change this line...
<File name="jmeter-log" fileName="${sys:jmeter.logfile:-jmeter.log}" append="false">
...to something like this:
<File name="jmeter-log" fileName="jmeter-${date:yyyyMMdd-hh-mm-ss}.log" append="false">
More information: How to Configure JMeter Logging