So I have the following task in gradle that sucessfully runs the selected simulation:
task runLoadTest(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
// Gatling application
main = “com.excilys.ebi.gatling.app.Gatling”
// Specify the simulation to run
args = Eval.me("[’-s’, ‘loadTests.EtollLoadTest’]")
//("[’-s’, ‘loadTests.EtollLoadTest’]")
}
However, it outputs a lot of unnecessary information in my terminal window. What I want is to see standard output about active sessions and requests (the same that you usually see when running simulation through gatling.sh script). Is it possible?
Hi,
I think that you’re missing a logback.xml in your classpath, so Gatling prints out all debug information.The logback.xml found in the bundle’s conf/ folder, put in /src/main/resources, should do it.
Cheers,
Pierre
Thanks for you quick reply! In src/main/resources folder I created folder conf, where I put empty logback.xml files. But the process didn’t change.
I edited the script and added
sourceSets {
main {
scala {
srcDirs = [‘src/main/scala’]
}
}
main {
resources {
srcDirs = [’/src/main/resources’]
}
}
}
but it’s still the same.
I think there’s a tiny misunderstanding here : You need to put the logback.xml file that can be found in the conf/ folder into the src/main/resource folder.
With your current setup :
- Move logback.xml up, right into the src/main/resources folder, and remove the conf folder.
- Copy this into your logback.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
<immediateFlush>false</immediateFlush>
</encoder>
</appender>
<!-- Uncomment for logging ALL HTTP request and responses -->
<!-- <logger name="io.gatling.http" level="TRACE" /> -->
<!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
<!-- <logger name="io.gatling.http" level="DEBUG" /> -->
<root level="WARN">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
I did what you told me and deleted the script that I added and it worked like a charm. Thank you so much. You made my day.
You’re welcome, glad I could help
Have fun with Gatling !
Cheers,
Pierre
And is it possible to modify logback.xml file so gatling would not also make reports but write logfiles for each execution?
I have notice in logback.xml file
What if i run simulation YYY and it creates report folder YYY-20140907XXXXXX. Can I make logback.xml write all http request and responses logging into the same folder?
Sorry, but you can’t.
You can setup Logback throught the logback.xml file to write logs to a file, or somewhere else, by configuring which ‘Appender’ to use (see http://logback.qos.ch/manual/appenders.html).
But Logback is its own subsystem, and is a no way capable of knowing the name of the latest Gatling’s report folder.
AFAIK, the best thing you could do to achieve this would be to write a wrapper script for gatling.sh which:
- Starts Gatling using gatling.sh
- Finds the lastest created folder in the reports folder, which has all the chances to be a new report from Gatling
- Copies the log file produced by Logback into the report folder.
Hope this helps.
Cheers,
Pierre
Well, at the moment my logback.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx
false
${TARGET}/gatling_additional-${TIMESTAMP}.log
%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx
false
It creates the log files, but they are empty. What could be the problem?
You need to configure a logger that uses your appender, e.g.,
Or if you want everything going to the file, you can do this:
Or add appenders to the gatling loggers, etc…
I tried to configuring a logger
and also tried to add this:
But the result is the same - log file is empty.
If you want more logging info written to your log file, you’ll need to change the level to “DEBUG” or even “TRACE”, like this :
Please note that I removed the CONSOLE appender from the list of appenders of the root logger, or you’ll otherwise have the same problem that you tried to solve, eg. having all the debug info printed out to the standard output.
Configuring your own logger will only log messages you call it for in your simulation. Forgot to mention that, sorry. If you want all loggers to go to the file, use the root logger (see Pierre’s post).
Thank you guys. Now log files are being filled with data. The only bad thing however is that I use the simulation name in logback.xml file:
${TARGET}/loadtest-${TIMESTAMP}/logfile.log
Maybe I could somehow use instead of “loadtest” some variable which shows what simulation is being run?