logging application results in a file implementation options

Hello,

I need to implement an output file for my tests with gatling. Basically, the scenario is taking a csv of subscriptions IDs to work on, another csv for users.
This subscription scenario has multiple cases in it, it can be green (accepted), orange (waiting for approval of a manager), red (refused) or black (technical error).

What I need is to output a csv/log file giving me for each input subscription ID the matching colored result.
Do you think logback can be used to do this directly from gatling dsl ? Or should I write a custom check or another component so i can output directly to log file

Best regards,
Benoit

Hello,

Absolutely, you can use Logback. Create the logger and then, just call it from an exec() block.
exec((session:Session) => logger.info(“lorem ipsum”); session)

Does this help you?

cheers
Nicolas

Hello,

I have a similar scenario wherein I want to write logs to a file. I tried the below:

  1. modified logback.xml to declare the new log file.
  2. Inside the code, wrote - val logger = org.slf4j.LoggerFactory.getLogger(“myUserTracker”)
    logger.info(“ggg”)
    But nothing is written to log file though the file is created.

Could you help?

We don’t do anything funky with slf4j/logback, so I think the problem is either with your logback config, or your code never being called.

Does your log appear in the console?

yes it is appearing in the console.

I have attached the logback-test.xml and below is my code.

val scnPE = scenario(“test”)

.feed(csv(“simple2.csv”))(session:Session) => logger.debug(“lorem ipsum”); session)

.exec(http(“Trigger”)

.post("/ppt")

.body(new StringBody(""“sample”""))

.headers(headers_4)

.check(status.is(200)))

logback-test.xml (885 Bytes)

The problem is with your logback config: there’s no logger appending to your FILE appender.

Thank you so much, I figured it out and am able to log info properly. Mistake from my side.

Glad to hear!

Have fun!