I have created a maven project that will generate a jar file with all my simulations in it and when I run it, the console log level is too high. There is too much unusefull informations for me. Is there a way to configure it in the code ? Here is my code:
import io.gatling.app.Gatling
import io.gatling.core.config.GatlingPropertiesBuilder
import io.gatling.core.config.GatlingConfiguration
object Engine extends App {
val props = new GatlingPropertiesBuilder
if(System.getProperty("resultsFolder") == null){
props.resultsDirectory("results")
}else{
props.resultsDirectory(System.getProperty("resultsFolder"))
}
props.dataDirectory("data")
props.simulationClass(System.getProperty("simulationClass"))
Gatling.fromMap(props.build)
sys.exit()
}
And here is the tree of my directory:
¦ dependency-reduced-pom.xml
¦ pom.xml
¦
+---src
+---main
¦ +---resources
¦ +---scala
¦ +---myPackage
¦ ¦ Engine.scala
¦ ¦
¦ +---simulation
¦ BasicSimulation.scala
¦
+---test
+---resources
¦ application.conf
¦ gatling.conf
¦ logback-test.xml
¦
+---scala
Placeholder.scala
The .config files and logback are the default ones of Gatling.
Here is how you do it:
package gatling.simulations
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import org.slf4j.LoggerFactory
import ch.qos.logback.classic.{Level, LoggerContext}
class FooSimulation extends Simulation {
val context: LoggerContext = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
// Log all HTTP requests
context.getLogger("io.gatling.http").setLevel(Level.valueOf("TRACE"))
// Log failed HTTP requests
//context.getLogger("io.gatling.http").setLevel(Level.valueOf("DEBUG"))
...
I have found a solution: put the log level in the Engine instead of reaing the logbaxk.xml file:
import io.gatling.app.Gatling
import io.gatling.core.config.GatlingPropertiesBuilder
import io.gatling.core.config.GatlingConfiguration
import org.slf4j.LoggerFactory
import java.util.logging.{Level, Logger}
object Engine extends App {
LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME).asInstanceOf[Logger].setLevel(Level.WARNING)
val props = new GatlingPropertiesBuilder
if(System.getProperty("resultsFolder") == null){
props.resultsDirectory("results")
}else{
props.resultsDirectory(System.getProperty("resultsFolder"))
}
props.dataDirectory("data")
props.simulationClass(System.getProperty("simulationClass"))
Gatling.fromMap(props.build)
sys.exit()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With