How can I integrate logger in Katelon Studio?

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.

I want to customize my log file like we do it in java api log4j, https://logging.apache.org/log4j/2.x/

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

we can use logger services with all log levels

3 Likes

Upvoted: Good work, Aman!

It would be fabulous if you could fully document the steps you took and post this a proper TIP document in https://forum.katalon.com/categories/tips-and-tricks.

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.

nice aman, +1

Hello All,

Someone can inform, how can i generate log files on local for my test?

good morning… this link seems broken… can you forward us the new tips and tricks url.?
Thanks in Advanced

hi Aman,
I tried adding the above details in log.properties file. After taht where do we need to configure? Could you please provide the steps.