Configuration on logs execution file

Hi
I am doing the web application testing. Is there anyways to reduce the log details to display the message and date only, and how to set the date without T and z

I have tried to change the logback.xml but it is still the same (have t and z on the date)

logs picture:

1 Like

No. You can not customize the format of the <katalon project>/Reports/yyyymmdd_hhMMss/tsName/yyyymmdd_hhMMss/execution0.log file.


The <record> in the execution0.log file contains this:

image

This implies that the execution0.log file is written by com.kms.katalon.core.logging.XmlKeywordLogger class.

You can read the source code of this class in <Katalon Studio installed directory>/Contents/Eclipse/configuration/resources/source/com.kms.katalon.core/com.kms.katalon.core-sources.jar. The line#78 looks as:

                   fileHandler.setFormatter(new CustomXmlFormatter());

So the com.kms.katalon.core.logging.CustomXmlFormatter class determines how each LogRecords are formatted into XML string representation. You can read the source of the CustomXmlFormatter class as well.

If you read the source, you can find that the com.kms.katalon.core.logging.CustomXmlFormatter class uses the java.util.logging package, not the logback.

I made a simple Test Case script that mimics how the CustomXmlFormatter class utilizes the java.util.logging package:

import java.util.logging.Level
import java.util.logging.LogRecord
import java.util.logging.XMLFormatter

LogRecord logRecord = new LogRecord(Level.INFO, "Merry Christmas!")
String formattedText = new XMLFormatter().format(logRecord)
println formattedText

You can copy & paste this test case script into your Katalon Studio and run it.

When I ran this, I got the following output in the console:

2024-12-23 18:00:17.605 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2024-12-23 18:00:17.608 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/testJavaUtilLoggingClasses
<record>
  <date>2024-12-23T09:00:18.116037Z</date>
  <millis>1734944418116</millis>
  <nanos>37000</nanos>
  <sequence>3</sequence>
  <level>INFO</level>
  <thread>1</thread>
  <message>Merry Christmas!</message>
</record>

2024-12-23 18:00:18.186 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/testJavaUtilLoggingClasses

The CustomXmlFormatter class uses the bare java.util.logging.XMLFormatter.format() method without any customization.

Please find the <date> element has a content text 2024-12-23T09:00:18.116037Z. This is exactly the same as the text found in the execution0.log. The date text contains T and Z, which @testlms21102024 wants to erase.

However, Katalon Studio provides no way for @testlms21102024 to customize the CustomXmlFormatter. Please, don’t ask me why.

Katalon Studio uses the java.util.logging package to write logs into the execution0.log file in the Reports folder, which is used as the source to compile the reports in HTML format, etc.

Also, Katalon Studio uses the logback to write logs into the console tab in the Katalon Studio GUI.

I don’t know why Katalon Studio uses these 2 logging frameworks intermixed.

@testlms21102024

You should be able to write a Groovy script that reads a execution0.log XML file and filter the contents into whatever format you like.

ok tqvm for guides

PLS have a look at the post:

where I demostrated how to transform an execution0.log file into another smaller XML file.

wow, Thank you once again

Hi @kazurayam, is there any way to configure the Katalon report to be generated before running the log filter test cases, after the main test cases in the same test suite?

For example, test case A is the main test case, and test case B is the log filter test case. When I put them in the same test suite for a seamless process, I use a test listener to get the latest folder timestamp to use as the path to the log. However, I encounter an issue where the log and all reports are created at the end of the test suite execution. Therefore, there won’t be any execution.log file in the report folder before the test suite execution ends.

1 Like

I developed a Test Case named monitorReportFolder:

import java.nio.file.Files;
import java.nio.file.Path
import java.nio.file.Paths
import java.util.stream.Collectors
import java.util.stream.Stream

import com.kms.katalon.core.configuration.RunConfiguration

Path reportFolder = Paths.get(RunConfiguration.getReportFolder())
println "reportFolder=${reportFolder}"
Stream<Path> stream = Files.list(reportFolder)
Set<Path> childFiles = 
	stream.filter({p -> !Files.isDirectory(p)})
		.collect(Collectors.toSet())
		
for (Path p in childFiles) {
	println p.toString() + " " + p.toFile().length() + " bytes"
}

Path log = reportFolder.resolve("execution0.log")
String content = Files.readString(log)
println content

When I ran it, I got the following result:

2025-01-10 18:39:12.515 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2025-01-10 18:39:12.519 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/monitorReportDirectory
reportFolder=/var/folders/7m/lm7d6nx51kj0kbtnsskz6r3m0000gn/T/Katalon/Test Cases/monitorReportDirectory/20250110_183907
/var/folders/7m/lm7d6nx51kj0kbtnsskz6r3m0000gn/T/Katalon/Test Cases/monitorReportDirectory/20250110_183907/execution0.log 5769 bytes
/var/folders/7m/lm7d6nx51kj0kbtnsskz6r3m0000gn/T/Katalon/Test Cases/monitorReportDirectory/20250110_183907/execution.properties 2865 bytes
/var/folders/7m/lm7d6nx51kj0kbtnsskz6r3m0000gn/T/Katalon/Test Cases/monitorReportDirectory/20250110_183907/execution0.log.lck 0 bytes
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
  <date>2025-01-10T09:50:50.562856Z</date>
  <millis>1736502650562</millis>
  <nanos>856000</nanos>
  <sequence>0</sequence>
  <level>START</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>startTest</method>
  <thread>1</thread>
  <message>Start Test Case : Test Cases/monitorReportDirectory</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
  <property name="name">Test Cases/monitorReportDirectory</property>
  <property name="description"></property>
  <property name="iteration"></property>
  <property name="id">Test Cases/monitorReportDirectory</property>
  <property name="source">\Users\kazuakiurayama\katalon-workspace\KatalonStudio_transforming_execution0.log_by_XSLT\Test Cases\monitorReportDirectory.tc</property>
  <property name="tag"></property>
  <property name="isOptional">false</property>
</record>
<record>
  <date>2025-01-10T09:50:50.968553Z</date>
  <millis>1736502650968</millis>
  <nanos>553000</nanos>
  <sequence>2</sequence>
  <level>START</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>startKeyword</method>
  <thread>1</thread>
  <message>Start action : reportFolder = Paths.get(getReportFolder())</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
  <property name="startLine">9</property>
  <property name="stepIndex">1</property>
</record>
<record>
  <date>2025-01-10T09:50:50.982597Z</date>
  <millis>1736502650982</millis>
  <nanos>597000</nanos>
  <sequence>3</sequence>
  <level>END</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>endKeyword</method>
  <thread>1</thread>
  <message>End action : reportFolder = Paths.get(getReportFolder())</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
</record>
<record>
  <date>2025-01-10T09:50:50.983153Z</date>
  <millis>1736502650983</millis>
  <nanos>153000</nanos>
  <sequence>4</sequence>
  <level>START</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>startKeyword</method>
  <thread>1</thread>
  <message>Start action : println(reportFolder=$reportFolder)</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
  <property name="startLine">10</property>
  <property name="stepIndex">2</property>
</record>
<record>
  <date>2025-01-10T09:50:51.036388Z</date>
  <millis>1736502651036</millis>
  <nanos>388000</nanos>
  <sequence>5</sequence>
  <level>END</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>endKeyword</method>
  <thread>1</thread>
  <message>End action : println(reportFolder=$reportFolder)</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
</record>
<record>
  <date>2025-01-10T09:50:51.037715Z</date>
  <millis>1736502651037</millis>
  <nanos>715000</nanos>
  <sequence>6</sequence>
  <level>START</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>startKeyword</method>
  <thread>1</thread>
  <message>Start action : stream = Files.list(reportFolder)</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
  <property name="startLine">11</property>
  <property name="stepIndex">3</property>
</record>
<record>
  <date>2025-01-10T09:50:51.054223Z</date>
  <millis>1736502651054</millis>
  <nanos>223000</nanos>
  <sequence>7</sequence>
  <level>END</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>endKeyword</method>
  <thread>1</thread>
  <message>End action : stream = Files.list(reportFolder)</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
</record>
<record>
  <date>2025-01-10T09:50:51.054949Z</date>
  <millis>1736502651054</millis>
  <nanos>949000</nanos>
  <sequence>8</sequence>
  <level>START</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>startKeyword</method>
  <thread>1</thread>
  <message>Start action : childFiles =  }).collect(Collectors.toSet())</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
  <property name="startLine">12</property>
  <property name="stepIndex">4</property>
</record>
<record>
  <date>2025-01-10T09:50:51.126871Z</date>
  <millis>1736502651126</millis>
  <nanos>871000</nanos>
  <sequence>9</sequence>
  <level>END</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>endKeyword</method>
  <thread>1</thread>
  <message>End action : childFiles =  }).collect(Collectors.toSet())</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
</record>
<record>
  <date>2025-01-10T09:50:51.127595Z</date>
  <millis>1736502651127</millis>
  <nanos>595000</nanos>
  <sequence>10</sequence>
  <level>START</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>startKeyword</method>
  <thread>1</thread>
  <message>Start action : for (java.nio.file.Path p : childFiles)</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
  <property name="startLine">16</property>
  <property name="stepIndex">5</property>
</record>
<record>
  <date>2025-01-10T09:50:51.140995Z</date>
  <millis>1736502651140</millis>
  <nanos>995000</nanos>
  <sequence>11</sequence>
  <level>START</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>startKeyword</method>
  <thread>1</thread>
  <message>Start action : println(p.toString() + &amp;quot; &amp;quot; + toFile().length() + &amp;quot; bytes&amp;quot;)</message>
  <nestedLevel>2</nestedLevel>
  <escapedJava>false</escapedJava>
  <property name="startLine">17</property>
  <property name="stepIndex">1</property>
</record>
<record>
  <date>2025-01-10T09:50:51.176717Z</date>
  <millis>1736502651176</millis>
  <nanos>717000</nanos>
  <sequence>12</sequence>
  <level>END</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>endKeyword</method>
  <thread>1</thread>
  <message>End action : println(p.toString() + &amp;quot; &amp;quot; + toFile().length() + &amp;quot; bytes&amp;quot;)</message>
  <nestedLevel>2</nestedLevel>
  <escapedJava>false</escapedJava>
</record>
<record>
  <date>2025-01-10T09:50:51.177676Z</date>
  <millis>1736502651177</millis>
  <nanos>676000</nanos>
  <sequence>13</sequence>
  <level>START</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>startKeyword</method>
  <thread>1</thread>
  <message>Start action : println(p.toString() + &amp;quot; &amp;quot; + toFile().length() + &amp;quot; bytes&amp;quot;)</message>
  <nestedLevel>2</nestedLevel>
  <escapedJava>false</escapedJava>
  <property name="startLine">17</property>
  <property name="stepIndex">1</property>
</record>
<record>
  <date>2025-01-10T09:50:51.179775Z</date>
  <millis>1736502651179</millis>
  <nanos>775000</nanos>
  <sequence>14</sequence>
  <level>END</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>endKeyword</method>
  <thread>1</thread>
  <message>End action : println(p.toString() + &amp;quot; &amp;quot; + toFile().length() + &amp;quot; bytes&amp;quot;)</message>
  <nestedLevel>2</nestedLevel>
  <escapedJava>false</escapedJava>
</record>
<record>
  <date>2025-01-10T09:50:51.180553Z</date>
  <millis>1736502651180</millis>
  <nanos>553000</nanos>
  <sequence>15</sequence>
  <level>START</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>startKeyword</method>
  <thread>1</thread>
  <message>Start action : println(p.toString() + &amp;quot; &amp;quot; + toFile().length() + &amp;quot; bytes&amp;quot;)</message>
  <nestedLevel>2</nestedLevel>
  <escapedJava>false</escapedJava>
  <property name="startLine">17</property>
  <property name="stepIndex">1</property>
</record>
<record>
  <date>2025-01-10T09:50:51.187120Z</date>
  <millis>1736502651187</millis>
  <nanos>120000</nanos>
  <sequence>16</sequence>
  <level>END</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>endKeyword</method>
  <thread>1</thread>
  <message>End action : println(p.toString() + &amp;quot; &amp;quot; + toFile().length() + &amp;quot; bytes&amp;quot;)</message>
  <nestedLevel>2</nestedLevel>
  <escapedJava>false</escapedJava>
</record>
<record>
  <date>2025-01-10T09:50:51.187831Z</date>
  <millis>1736502651187</millis>
  <nanos>831000</nanos>
  <sequence>17</sequence>
  <level>END</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>endKeyword</method>
  <thread>1</thread>
  <message>End action : for (java.nio.file.Path p : childFiles)</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
</record>
<record>
  <date>2025-01-10T09:50:51.188331Z</date>
  <millis>1736502651188</millis>
  <nanos>331000</nanos>
  <sequence>18</sequence>
  <level>START</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>startKeyword</method>
  <thread>1</thread>
  <message>Start action : log = reportFolder.resolve(&amp;quot;execution0.log&amp;quot;)</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
  <property name="startLine">20</property>
  <property name="stepIndex">6</property>
</record>
<record>
  <date>2025-01-10T09:50:51.194453Z</date>
  <millis>1736502651194</millis>
  <nanos>453000</nanos>
  <sequence>19</sequence>
  <level>END</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>endKeyword</method>
  <thread>1</thread>
  <message>End action : log = reportFolder.resolve(&amp;quot;execution0.log&amp;quot;)</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
</record>
<record>
  <date>2025-01-10T09:50:51.195700Z</date>
  <millis>1736502651195</millis>
  <nanos>700000</nanos>
  <sequence>20</sequence>
  <level>START</level>
  <class>com.kms.katalon.core.logging.XmlKeywordLogger</class>
  <method>startKeyword</method>
  <thread>1</thread>
  <message>Start action : content = Files.readString(log)</message>
  <nestedLevel>1</nestedLevel>
  <escapedJava>false</escapedJava>
  <property name="startLine">21</property>
  <property name="stepIndex">7</property>
</record>

2025-01-10 18:50:51.224 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/monitorReportDirectory

You can see that the execution0.log file created by this Test Case is found in a location under the temporary directory that Java Runtime Environment manages. But the exact folder location of exectuion0.log does not matter much to you, as you can retrieve the location and you can read the file, as this sample code does.

I noticed that the content of execution0.log was incomplete in that it does not contain the <record> of the very last Groovy statement

println content.

Also you should note that the content of the observed execution0.log is a mal-formed XML. It misses a closing </log> tag.

I think that the monitorReportFolder does something brutal. But @testlms21102024 may find it applicable to his case.

If you have a Katalon Runtime Engine license, you can solve the problem by introducing an extra level of indirection.

You want to create a bash script or a PowerShell script that does

  1. execute KRE to run a Test Suite that does your business
  2. after the Test Suite finished, the script executes KRE to run another Test Suite that does filtering the log of previous Test Suite run.

oh ok tqvm