During my load test, my virtual users create some reports. I would like to store all the id's of these reports into an external file. I know that I can use your API logger through javascript but I would like to store on a specific path on my servers.
Neoload offers the possibility to log information into a file using a javascript. The javascript API contains a method called "logger" that will let you store information for each virtual user.
The output is located in the load generator log files. A the end of the test, the Neoload controller will get all the load generator logs and they will be displayed in the "Results" section under "logs" tab.
If you want to write content in your own file on the load generator file system, you have to handle it manually.
Here is an example of javascript code to achieve that: Here is the javascript with a function definition that can be saved in the Neoload js libraries folder:
var lock = new java.util.concurrent.locks.ReentrantLock();
var date = context.variableManager.getValue("CurrentDate");
if (date==null)
{
context.fail("Variable 'CurrentDate' not found");
}
function writeFile(text)
{
lock.lock();
var writer = new java.io.FileWriter("c:\\log.txt",true); writer.write(date+";"+context.currentVU.id+";"+text); writer.write("\r\n");
writer.close();
lock.unlock();
}
And then create this kind of javascript to use that function:
var cpt = context.variableManager.getValue("StringRandom");
if (cpt==null)
{
context.fail("Variable 'StringRandom' not found");
}
writeFile(cpt+";was the value from my test");
For more information, see "NeoLoad Javascript API" in NeoLoad documentation.