Gatling logging is not working for ERROR

This is the logback.xml that I’m currently using

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <timestamp key="startTimestamp" datePattern="yyyy-MM-dd_HH-mm"/>

  <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>

  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>gatling.${startTimestamp}.log</file>
    <immediateFlush>false</immediateFlush>

    <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
    </encoder>
  </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="ERROR" />

  <!-- uncomment to log WebSocket events -->
  <!--<logger name="io.gatling.http.action.ws.fsm" level="DEBUG" />-->

  <!-- uncomment to log SSE events -->
  <!--<logger name="io.gatling.http.action.sse.fsm" level="DEBUG" />-->

  <root level="ERROR">
    <appender-ref ref="FILE" />
  </root>

</configuration>

The problem is: it’s not logging failed requests as "ERROR’, so there’s nothing to log when running gatling using ERROR log level.

When I change it to “DEBUG” or “TRACE” it works ok, but the failing requests are not logged as “ERROR” →

11:16:45.355 [DEBUG] i.g.h.e.r.DefaultStatsProcessor - Request 'Test - get all companies' failed for user 1: status.find.in([200, 209], 304), found 404
11:16:45.356 [TRACE] i.g.h.e.r.DefaultStatsProcessor - 
>>>>>>>>>>>>>>>>>>>>>>>>>>
Request:
Test - get all companies: KO status.find.in([200, 209], 304), found 404```

is there anything that i can do to make gatling log only the failing requests?

Hi @Vinicius,

I’m sorry, I don’t get what you are asking.

To receive a 404 is not a (gatling) error. And for some simulation, it is a required situation.
To log a request is only available for debugging purpose, but it’s not sustainable for full power simulation (too many things to write)

What is the possible implementation that cover all the simulation for all our users?

  • We cannot store the requests each time (or we will blow up the RAM)
  • We cannot know if the request is an error before the checks
  • We cannot assume 404 is a error (at the request time)

In this situation, what do you suggest?

Cheers,

1 Like

@Vinicius I think you misunderstand how Java logging frameworks work, including logback.

In the configuration file, you don’t configure the level of each message, you configure the enabled levels (globally, and packages overrides).

As @sbrevet explained, a failed request in not a blocking ERROR from Gatling’s point of view. An engine crash is.

1 Like

Hi @sbrevet ,

Well, I’m sorry for the misunderstood.
I tried to add different checks in my http requests to see if gatling would log them in a different manner, as both are getting 404 http but only one of them is really expected to get a 404 status.
Also, I changed the log level to DEBUG. Acording to the logback docs, the DEBUG level is used to log the failing requests.

<!-- 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="DEBUG" />
 def getContacts = {
    exec(
      http("Test - get all contacts")
      .get("/v1/contacts")
        .check(status.is(200))
    )
  }

  def getCompanies = {
    exec(
      http("Test - get all companies")
        .get("/v1/companies")
        .check(status.is(404))
    )
  }

But I still got logs for both requests, because they’re logged with “DEBUG” level.
Any hint?

So, you want to log the same thing (a request), with same behavior (404) when your code is the one to differentiate one from the other.

I don’t see anything that gatling (or any library) can do here.

You can log something when the session isFailed, but you have to take care to clean this state as you want if you use a loop (for instance).

Sorry, but again, I don’t see what we can do here.

Cheers!

Hi @sbrevet,

Ok, now i undertand that checkings won’t work the way I thought
But the point is, what does the documentation means by “failling HTTP requests”?
When using DEBUG level combined or not with checks, I see the same behavior: It logs all requests, even if it’s a failling HTTP request or not.

A failing request:

  • either experienced an IO failure (connect timeout, connection refused, TLS handshake timeout, request timeout, etc)
  • or has a defined check that failed

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.