Request: Turn on debug logging with command-line flag

2,249 views
Skip to first unread message

John Arrowwood

unread,
Sep 30, 2014, 1:06:26 PM9/30/14
to gat...@googlegroups.com
Most of the time, I don't like to have debug logging turned on, because it is a little too verbose.

But when I am in active development and things are going weird, it can be nice to have all that debug information.

Is there already a way to override the .conf file to turn on debug logging, and if not, would you consider it for 2.1?

Stéphane Landelle

unread,
Sep 30, 2014, 5:31:32 PM9/30/14
to gat...@googlegroups.com
gatling.conf can't do anything about logging, logback.xml can.
What's the difference between editing gatling.conf instead of editing logback.xml?
Then, you know you can use System properties in your logback.xml, right?

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

John Arrowwood

unread,
Sep 30, 2014, 8:45:17 PM9/30/14
to gat...@googlegroups.com
I did not know that I can use System Properties in my logback.xml.  Can you give me a simple example of that to get me started?

Stéphane Landelle

unread,
Oct 1, 2014, 1:38:36 AM10/1/14
to gat...@googlegroups.com

John Arrowwood

unread,
Oct 23, 2014, 11:46:37 AM10/23/14
to gat...@googlegroups.com
I'm trying to make this work as intended, and I am not having much luck.  Here's what I have:

<?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.ahc.AsyncHandlerActor" level="TRACE" />
 
<!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
 
<!--  <logger name="io.gatling.http.ahc.AsyncHandlerActor" level="DEBUG" /> -->

 
<root level="${httpLogging:-WARN}">
   
<appender-ref ref="CONSOLE" />
 
</root>

</configuration>


What I expected was that I would only see the TRACE logs if httpLogging was set to TRACE.  Instead, the TRACE logs are displaying unconditionally.

How do I need to tweak this so that it does what I intended?

Stéphane Landelle

unread,
Oct 23, 2014, 12:00:14 PM10/23/14
to gat...@googlegroups.com
Loggers are a hierarchy: the one defined for root gets overridden for io.gatling.http.ahc.AsyncHandlerActor.

John Arrowwood

unread,
Oct 23, 2014, 2:41:17 PM10/23/14
to gat...@googlegroups.com
I get it.  By re-commenting out the AsyncHandlerActor, then it honors my setting.  Perfect!  Thanks! :)

John Arrowwood

unread,
Oct 23, 2014, 4:11:38 PM10/23/14
to gat...@googlegroups.com
Related question:

What do I need to put in my code, instead of "println()" in order to log to the DEBUG level, so that my debug output is only output when the logging level is set to DEBUG or lower?

Stéphane Landelle

unread,
Oct 23, 2014, 6:11:10 PM10/23/14
to gat...@googlegroups.com
Gatling uses scala-logging, a nice wrapper on top of slf4j.
Either use it or bare slf4j.

John Arrowwood

unread,
Oct 24, 2014, 12:46:15 PM10/24/14
to gat...@googlegroups.com
Not sure how to make it work...

The link you sent says it requires Scala 2.11.  Gatling ships with Scala 2.10.  But that' can't be the problem, because...

I looked at the source code of Gatling, e.g. gatling-core/src/main/scala/io/gatling/core/session/Session.scala,
it imports com.typesafe.scalalogging.StrictLogging, and then just extends StrictLogging, exactly like the website you linked to,
but when I do that, I get a compile error:

09:37:24.697 [ERROR] i.g.a.ZincCompiler$ - /src/poc/rtde/src/scala/com/cigna/common/SessionManagement.scala:4: object StrictLogging is not a member of package com.typesafe.scalalogging
09:37:24.700 [ERROR] i.g.a.ZincCompiler$ - import com.typesafe.scalalogging.StrictLogging
09:37:24.701 [ERROR] i.g.a.ZincCompiler$ -        ^

Thoughts?

Stéphane Landelle

unread,
Oct 24, 2014, 1:04:37 PM10/24/14
to gat...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages