serenity-bdd / serenity-core

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.
http://serenity-bdd.info
Other
720 stars 519 forks source link

Is there a way to control the console logging in serenity? #2640

Closed prasadautomationtesting closed 2 years ago

prasadautomationtesting commented 2 years ago

I could see so many are being logged in console which makes life difficult to debug. Is there way to keep it quiet?

serenity.properties:-

serenity.restart.browser.for.each=FEATURE serenity.maintain.session=true serenity.take.screenshots=FOR_EACH_ACTION serenity.console.colors=true serenity.logging=QUIET

Sample console logs of mine are:-

Request DefaultHttpRequest(decodeResult: success, version: HTTP/1.1) POST /session/werwer/element HTTP/1.1 User-Agent: selenium/4.0.0 (java windows) Content-Length: 53 Content-Type: application/json; charset=utf-8 host: localhost:23523 accept: /

Response DefaultHttpResponse(decodeResult: success, version: HTTP/1.1) HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 cache-control: no-cache content-length: 88

22:05:33.482 [AsyncHttpClient-1-2] DEBUG o.a.netty.channel.ChannelManager - Adding key: http://localhost:124 for channel [id: rwery, L:/123.0.0.1:123 - R:localhost/123.0.0.1:123] 22:05:33.508 [Forwarding isElementDisplayed on session werywer to remote] DEBUG o.a.netty.request.NettyRequestSender - Using pooled Channel '[id: weryewr, L:/999.0.0.1:123 - R:localhost/123.0.0.1:123]' for 'POST' to 'http://localhost:213/session/00d77e8745f7623523aaabd8a61ac/execute/sync' 22:05:33.508 [Forwarding isElementDisplayed on session 235 to remote] DEBUG o.a.netty.request.NettyRequestSender - Using open Channel [id: werywery, L:/123.0.0.1:qwywry - R:localhost/123.0.0.1:123] for POST '/session/23523/execute/sync' 22:05:33.557 [AsyncHttpClient-1-2] DEBUG o.a.netty.handler.HttpHandler -

Request DefaultHttpRequest(decodeResult: success, version: HTTP/1.1) POST /session/foobooaaabd8a61ac/execute/sync HTTP/1.1 User-Agent: selenium/4.0.0 (java windows) Content-Length: 48780 Content-Type: application/json; charset=utf-8 host: localhost:235325 accept: /

Response DefaultHttpResponse(decodeResult: success, version: HTTP/1.1) HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 cache-control: no-cache content-length: 14

pom.xml:-

net.serenity-bdd serenity-cucumber 3.1.10 net.serenity-bdd.maven.plugins serenity-maven-plugin ${serenity.version} ${tags} serenity-reports post-integration-test aggregate 8 8 UTF-8 2.6.0 UTF-8
wakaleo commented 2 years ago

Serenity uses LogBack, so you need to set up a logback configuration file. Here's an example:

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>
                %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
            </pattern>
        </encoder>
    </appender>
    <logger name="my.root.package" level="INFO"/>
    <root level="WARN">
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>