currently I'm looking in this Tinkoff's JDBC plugin for Gatling, when I enable TRACE log, the response time would be much higher, i.e from 1500ms to 25 seconds.
This is my Gatling logback.xml setting:
<?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>
</encoder>
<immediateFlush>false</immediateFlush>
</appender>
<!-- uncomment and set to DEBUG to log all failing HTTP requests -->
<!-- uncomment and set to TRACE to log all HTTP requests -->
<logger name="io.gatling.http.engine.response" level="TRACE" />
<!-- uncomment to log WebSocket events -->
<!-- <logger name="io.gatling.http.action.ws.fsm" level="TRACE" /> -->
<!-- uncomment to log SSE events -->
<!-- <logger name="io.gatling.http.action.sse.fsm" level="TRACE" /> -->
<!-- <root level="TRACE"> -->
<root level="TRACE">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
For connecting definition
object Actions_test {
// database connection
val database_URL: JdbcProtocolBuilder = DB
.url("mariadb")
.username("user")
.password("pw@2024")
.maximumPoolSize(10)
.connectionTimeout(10.second)
// large query
def callingJDBC(): QueryActionBuilder =
jdbc("simple Call")
.query("""your-large-query-here
""".stripMargin)
.check(simpleCheck(x => x.length > 2000)
)
}
for Scenario:
class DebugTest extends Simulation {
val scn = scenario("test")
.exec(Actions_test.callingJDBC())
.exitHere
setUp(
scn.inject(
rampUsers(1000).during(500)
),
)
.protocols(Actions_test.database_URL)
.maxDuration(10.minute)
}
How do I correctly configure logging for this plugin? please help me.
TL;DR
Setting log level to trace si not something that you are going to do frequently unless you really need to see lots of details of the program you are executing. Setting the root logger level of your app to
TRACEcould not be a good idea because you are going to see things from many many components (http client, db client, gatling, akka, etc). Something better could be to set the root logger level toWARNorINFOand set toTRACEsome specific loggers. Just as it is explained in the gatling logback dummy configNot sure what is your goal exactly or why you want to have a good performance with a
TRACElevel. Logback has appenders, in this case you are using the ConsoleAppender.This means that the logger is doing an I/O operation each time you log a message. You can set the property immediateFlush to
false(by default is true) to buffer the messages. This one comes from OutputStreamAppenderWhen you change from log level
INFOtoTRACE, you are increasing the amount of messages that the logger have to write. So, it's ok to see the performance reduced.From the Apache commons loggins library, you can read the following best practices for log level messages
That being said, if you really need to set the log level to
TRACEyou can try to play with the configuration of logback and use different appenders instead of using the default config provided by gatling.I recreated the case you detailed in your question locally with the following files
build.sbtproject/plugins.sbtsrc/gatling/BasicSimulation.scalasrc/gatling/resources/logback.xmldocker-compose.yamlthen we need to run the following commands to first start the database, create the table and populate it with some data
and finally we can run the gatling simulation with
You can run the gatling simulation as many times as you want with different logback configurations. You should be able to see that each time you set the root log level to
TRACEthere will be some impact in the performance