I want to integrate services like log4j, like if am writing some log messages in my tests cases ex: log.info(“”), log.error(“”), etc. these log messages should get printed in a log file which I can refer for failure test cases after executed.
After lots of RND found a way to use logger with Katelon Studio, first we have to create config file such as .properties file with all logger configuration
# Root logger option
log4j.rootLogger=INFO, file
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.Append=false
log4j.appender.file.File=C:\\log\\logging.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:(%F:%L) - %m%n
and then after setting path of config file as
PropertyConfigurator.configure("path of .properties file")
The best approach to take is to pretend you’re talking to yourself, six months ago and recall you knew nothing about using log4j or how to incorporate it in Katalon.
If you do this, I’m sure many people – including me – will appreciate it.