How to let SLF4J log messages from your custom classes printed in the Katalon Console

Just a small finding.

I wrote a Custom Keyword class: my.Keywords

package my

import org.slf4j.Logger
import org.slf4j.LoggerFactory

public class Keywords {

	private static Logger logger = LoggerFactory.getLogger(Keywords.class.getName())

	public static void hello(String name) {
		logger.info("Hello, " + name)
	}

	public static void howareyou(String name) {
		logger.warn("How are you? " + name)
	}

	public static void goodbye(String name) {
		logger.debug("Goodbye, " + name)
	}
}

As you see, this class emits log messages via SLF4J Logger.

I wrote a Test Cases/TC1

import my.Keywords

Keywords.hello("Fox")

Keywords.howareyou("Wolf")

Keywords.goodbye("Bear")

When I exected TC1, it prited no “Hello”, no “How are you”, no “Goodbye” in the Console of Katalon Studio GUI.

Log messages via SLF4J does not appear in the Console of Katalon Studio as default.


I edited <projectDir>/Include/config/log.properties file as follows

# This file is used to configure Katalon Studio execution log levels.

logging.level.testcase=INFO

logging.level.my.Keywords=DEBUG

Please note here I specified the log level for my.Keywords class to be DEBUG.

I executed TC1 again. I got the following message in the Console of Katalon Studio GUI.

2022-03-06 21:08:03.667 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2022-03-06 21:08:03.670 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/TC1
2022-03-06 21:08:04.222 INFO  my.Keywords                              - Hello, Fox
2022-03-06 21:08:04.226 WARN  my.Keywords                              - How are you? Wolf
2022-03-06 21:08:04.237 DEBUG my.Keywords                              - Goodbye, Bear
2022-03-06 21:08:04.260 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/TC1

The log messages from my classes via SLF4J Logger now appears.

1 Like