Run simulation script in build.gradle file

611 views
Skip to first unread message

Andrei Proskurin

unread,
Jul 9, 2014, 6:17:51 AM7/9/14
to gat...@googlegroups.com
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?

Pierre DAL-PRA

unread,
Jul 9, 2014, 6:22:47 AM7/9/14
to gat...@googlegroups.com
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

--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrei Proskurin

unread,
Jul 9, 2014, 6:26:45 AM7/9/14
to gat...@googlegroups.com
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.

Andrei Proskurin

unread,
Jul 9, 2014, 6:46:22 AM7/9/14
to gat...@googlegroups.com
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.


On Wednesday, July 9, 2014 1:22:47 PM UTC+3, Pierre DAL-PRA wrote:

Pierre DAL-PRA

unread,
Jul 9, 2014, 6:47:51 AM7/9/14
to gat...@googlegroups.com
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>

Andrei Proskurin

unread,
Jul 9, 2014, 6:54:02 AM7/9/14
to gat...@googlegroups.com
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.

Pierre DAL-PRA

unread,
Jul 9, 2014, 6:55:12 AM7/9/14
to gat...@googlegroups.com
You’re welcome, glad I could help :)
Have fun with Gatling !

Cheers, 

Pierre

Andrei Proskurin

unread,
Jul 9, 2014, 6:56:42 AM7/9/14
to gat...@googlegroups.com
And is it possible to modify logback.xml file so gatling would not also make reports but write logfiles for each execution?

Andrei Proskurin

unread,
Jul 9, 2014, 7:38:15 AM7/9/14
to gat...@googlegroups.com
I have notice in logback.xml file
<!-- Uncomment for logging ALL HTTP request and responses -->
    <!--     <logger name="io.gatling.http" level="TRACE" /> -->

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?

Pierre DAL-PRA

unread,
Jul 9, 2014, 8:39:34 AM7/9/14
to gat...@googlegroups.com
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

Andrei Proskurin

unread,
Jul 9, 2014, 8:46:19 AM7/9/14
to gat...@googlegroups.com
Well, at the moment my logback.xml looks like this:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property name="TARGET" value="target/gatling/results"/>
    <timestamp key="TIMESTAMP" datePattern="yyyyMMdd'T'HHmmss"/>


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

    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>
            ${TARGET}/gatling_additional-${TIMESTAMP}.log
        </file>

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

It creates the log files, but they are empty. What could be the problem?

Michelle Burrows

unread,
Jul 9, 2014, 8:51:39 AM7/9/14
to gat...@googlegroups.com
You need to configure a logger that uses your appender, e.g., 

    <logger name="myLogger" level="INFO">
            <appender-ref ref="FILE"/>
    </logger>

Or if you want everything going to the file, you can do this:

    <root level="WARN">
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="FILE" />
    </root>

Or add appenders to the gatling loggers, etc...

Andrei Proskurin

unread,
Jul 9, 2014, 9:04:12 AM7/9/14
to gat...@googlegroups.com
I tried to configuring a logger

<logger name="myLogger" level="INFO">
            <appender-ref ref="FILE"/>
    </logger>
and also tried to add this:
<appender-ref ref="FILE" />
But the result is the same - log file is empty.

Pierre DAL-PRA

unread,
Jul 9, 2014, 9:08:13 AM7/9/14
to gat...@googlegroups.com
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 :

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

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.

Michelle Burrows

unread,
Jul 9, 2014, 9:24:05 AM7/9/14
to gat...@googlegroups.com
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).

Andrei Proskurin

unread,
Jul 9, 2014, 9:25:49 AM7/9/14
to gat...@googlegroups.com
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:

<file>
${TARGET}/loadtest-${TIMESTAMP}/logfile.log
        </file>

Maybe I could somehow use instead of "loadtest" some variable which shows what simulation is being run?
Reply all
Reply to author
Forward
0 new messages